]> git.karo-electronics.de Git - karo-tx-linux.git/commit
Btrfs: do not bother to defrag an extent if it is a big real extent
authorLiu Bo <liubo2009@cn.fujitsu.com>
Thu, 29 Mar 2012 13:57:45 +0000 (09:57 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 29 Mar 2012 13:57:45 +0000 (09:57 -0400)
commit66c2689226ac322fbc9acd2e8e418b78dcd52f51
tree98da1733c2fc92e00c32c50199d1c85a43c1e6d0
parent17ce6ef8d731af5edac8c39e806db4c7e1f6956f
Btrfs: do not bother to defrag an extent if it is a big real extent

$ mkfs.btrfs /dev/sdb7
$ mount /dev/sdb7 /mnt/btrfs/ -oautodefrag
$ dd if=/dev/zero of=/mnt/btrfs/foobar bs=4k count=10 oflag=direct 2>/dev/null
$ filefrag -v /mnt/btrfs/foobar
Filesystem type is: 9123683e
File size of /mnt/btrfs/foobar is 40960 (10 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0     3072              10 eof
/mnt/btrfs/foobar: 1 extent found

Now we have a big real extent [0, 40960), but autodefrag will still defrag it.

$ sync
$ filefrag -v /mnt/btrfs/foobar
Filesystem type is: 9123683e
File size of /mnt/btrfs/foobar is 40960 (10 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0     3082              10 eof
/mnt/btrfs/foobar: 1 extent found

So if we already find a big real extent, we're ok about that, just skip it.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ioctl.c