On Tue, May 8, 2012 at 7:59 AM, Dave Chinner <david@xxxxxxxxxxxxx> wrote:
Thanks for pointing it out.
Close(fd) should be invoked before dd quits. But why the extra blocks beyond EOF are not freed?
The only way I found to remove the extra blocks is truncate the file to its real size.
On Mon, May 07, 2012 at 08:44:17PM +0800, Zhu Han wrote:You test case is not doing what you think it is doing.
> Seems like xfs of CentOS 6.X occupies much more storage space than desired
> if fallocate is used against the file. Here is the step to reproduce it:
Thanks for pointing it out.
That does a truncate first, removing all the preallocated space. Use
> By the way, is it normal when the file is moved around after the
> preallocated region is filled with data?
>
> $ uname -r
> 2.6.32-220.7.1.el6.x86_64
>
> $fallocate -n --offset 0 -l 1G file ---->Write a little more data than
> the preallocated size
>
> $ xfs_bmap -p -vv file
> file:
> EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET
> TOTAL FLAGS
> 0: [0..2097151]: 2593408088..2595505239 21 (29420144..31517295)
> 2097152 10000
>
> $ dd if=/dev/zero of=/tmp/file bs=1M count=1026 conv=fsync
conv=notrunc to avoid this. Hence the space allocated by this
new write is different to the space allocated by the above
preallocation. The file has not been moved, the filesystem just did
what you asked it to do.
And so now you've triggered the speculative delayed allocation
>
> $ xfs_bmap -p -vv file
> file:
> EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET
> TOTAL FLAGS
> 0: [0..4194303]: 2709184016..2713378319 22 (23101408..27295711)
> 4194304 00000
beyond EOF, which is normal behaviour. Hence there are currently
unused blocks beyond EOF which will get removed either when the next
close(fd) occurs on the file or the inode is removed from the cache.
Close(fd) should be invoked before dd quits. But why the extra blocks beyond EOF are not freed?
The only way I found to remove the extra blocks is truncate the file to its real size.
Cheers,
Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
_______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs