diff options
author | Liu Bo <liubo2009@cn.fujitsu.com> | 2012-03-29 09:57:45 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-03-29 09:57:45 -0400 |
commit | 66c2689226ac322fbc9acd2e8e418b78dcd52f51 (patch) | |
tree | 98da1733c2fc92e00c32c50199d1c85a43c1e6d0 /fs/btrfs/ioctl.c | |
parent | 17ce6ef8d731af5edac8c39e806db4c7e1f6956f (diff) |
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>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 6c39d1a55907..afde837644e5 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1140,12 +1140,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1140 | if (!(inode->i_sb->s_flags & MS_ACTIVE)) | 1140 | if (!(inode->i_sb->s_flags & MS_ACTIVE)) |
1141 | break; | 1141 | break; |
1142 | 1142 | ||
1143 | if (!newer_than && | 1143 | if (!should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT, |
1144 | !should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT, | 1144 | PAGE_CACHE_SIZE, extent_thresh, |
1145 | PAGE_CACHE_SIZE, | 1145 | &last_len, &skip, &defrag_end)) { |
1146 | extent_thresh, | ||
1147 | &last_len, &skip, | ||
1148 | &defrag_end)) { | ||
1149 | unsigned long next; | 1146 | unsigned long next; |
1150 | /* | 1147 | /* |
1151 | * the should_defrag function tells us how much to skip | 1148 | * the should_defrag function tells us how much to skip |