From: Dave Chinner <david@fromorbit.com>
To: huubby zhou <huubby1@gmail.com>
Cc: xfs@oss.sgi.com
Subject: Re: How to reserve disk space in XFS to make the blocks over many files continuous?
Date: Wed, 7 Nov 2012 14:19:52 +1100 [thread overview]
Message-ID: <20121107031952.GA6434@dastard> (raw)
In-Reply-To: <CANS6a=D4SMMqhGJVMLbr-BWqLb-Z4L4LnofzfhqChBvE9dEtPQ@mail.gmail.com>
On Wed, Nov 07, 2012 at 09:02:11AM +0800, huubby zhou wrote:
> 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).
it doesn't on more recent releases - it uses fallocate() in the back
end, which does the same as:
> then I tried
> *xfsctl()*<http://linux.die.net/man/3/xfsctl>,
> with *XFS_IOC_RESVSP* flag, I can reserve space faster.
This command.
> 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.
You can't, directly. If you have enough contiguous free space in the
AG that you are allocating in, then you will get contiguous files if
the allocation size lines up with the filesystem geometry:
$ for i in `seq 1 10` ; do sudo xfs_io -f -c "truncate 512m" -c "resvsp 0 512m" foo.$i ; done
$ sudo xfs_bmap -vp foo.[1-9] foo.10 |grep " 0:"
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL FLAGS
sudo xfs_bmap -vp foo.[1-9] foo.10 |grep " 0:"
0: [0..1048575]: 8096..1056671 0 (8096..1056671) 1048576 10000
0: [0..1048575]: 1056672..2105247 0 (1056672..2105247) 1048576 10000
0: [0..1048575]: 2105248..3153823 0 (2105248..3153823) 1048576 10000
0: [0..1048575]: 3153824..4202399 0 (3153824..4202399) 1048576 10000
0: [0..1048575]: 4202400..5250975 0 (4202400..5250975) 1048576 10000
0: [0..1048575]: 5250976..6299551 0 (5250976..6299551) 1048576 10000
0: [0..1048575]: 6299552..7348127 0 (6299552..7348127) 1048576 10000
0: [0..1048575]: 7348128..8396703 0 (7348128..8396703) 1048576 10000
0: [0..1048575]: 8396704..9445279 0 (8396704..9445279) 1048576 10000
0: [0..1048575]: 9445280..10493855 0 (9445280..10493855) 1048576 10000
So all those files are contiguous both internally and externally. If
there isn't sufficient contiguous freespace, or there is allocator
contention, this won't happen - it's best effort behaviour....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-11-07 3:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-07 1:02 How to reserve disk space in XFS to make the blocks over many files continuous? huubby zhou
2012-11-07 3:19 ` Dave Chinner [this message]
2012-11-09 2:04 ` huubby zhou
2012-11-09 3:08 ` Dave Chinner
2012-11-09 6:50 ` huubby zhou
2012-11-09 15:03 ` Roger Willcocks
2012-11-09 23:15 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121107031952.GA6434@dastard \
--to=david@fromorbit.com \
--cc=huubby1@gmail.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox