[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: How to reserve disk space in XFS to make the blocks over many files continuous?
From: huubby zhou <huubby1@xxxxxxxxx>
Date: Wed, 7 Nov 2012 09:02:11 +0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=6KCiO3/GpPjt9LMob03u+JLyEkcD1duVhokv1AtwgpA=; b=HXgj2bw2qBVxWUxMvU8CVFhN83lxxnYERcZDlhQSqd7CxR2BPIy9aT1cfx67DDiU7m 7vWRxjsuuwa0Z8gBkCgW3ATadWwgl2bxbF/ITSCQ+p+uMvyDqlQu9Qdv9diBK6C+PbHn yDZ6dkrNhQbavremMJ8ALW9gBfHjKJMFDshX1Wd23NQJIqCEc2stnsKJE87jryN1haxW QUG0Ho8Km6snrSQZs1zzoJ8DTT56YxcnBcI7h2pdiRhS1GB8Z7L/sSYOOPADT3BxIVAP MNdDXTmqkvo6bh14IxnwGg+8ljUJWyEg/tEA44DFwAa8ewA0hmCvbxAsyb3M5LE9ZzO6 3+Vg==
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(), 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.

<Prev in Thread] Current Thread [Next in Thread>