How to reserve disk space in XFS to make the blocks over many files continuous?

huubby zhou huubby1 at gmail.com
Tue Nov 6 19:02:11 CST 2012


Hi, folks,

I'm using *CentOS5.8*, with *XFS* filesystem extend storage disks. What I
want to do is, pre-allocating many files, with continuous blocks in
filesystem, both single file and crossing files. That is the start block ID
of the next file is following the end block ID of current file.

I could do space pre-allocation by *posix_allocate()*, problem is the API
zeros all disk space, I can't afford time consuming(I'm not sure if this
API could make the blocks continuous). then I tried
*xfsctl()*<http://linux.die.net/man/3/xfsctl>,
with *XFS_IOC_RESVSP* flag, I can reserve space faster.

The problem with *xfsctl()* is, it could make the blocks continuous for
individual file, but the blocks over files are *not* continuous. For
example, 10 files, a/b/c/d/e/f... reserved. After I do the real writing to
these files, it turns out the file 'b' isn't next to file 'a', and some
file could be far from both previous one and next one, though other files
may be neighboring with each other, rarely.

I use the following code to do the pre-allocation:

ftruncate(fd, FILE_SIZE);

xfs_flock_t flag = {0};
flag.l_whence = SEEK_SET;
flag.l_start  = 0;
flag.l_len    = 512*1024*1024;
xfsctl(fileName, fd, XFS_IOC_RESVSP64, &flag);

My question is, how can I guarantee the file system blocks over files
continuous? Thanks for your time and appreciate your answer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oss.sgi.com/pipermail/xfs/attachments/20121107/39b69bd2/attachment.htm>


More information about the xfs mailing list