Question

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.

I could do allocation by posix_allocate(), problem is the API zeros all disk space, I can't afford time consuming. then I tried the XFS specify API 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.

Was it helpful?

Solution

Got answer from the XFS mail list, this turns out is the problem of the default inode allocator. Mount with inode64, and if enough disk space is available in the AG, the files would be continuous both internally and externally. Since the default inode32 allocator, always try to rotate among AGs for each allocation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top