aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2012-06-19 21:08:32 -0400
committerChris Mason <chris.mason@fusionio.com>2012-07-23 15:41:39 -0400
commita43a21113365e5a9b59efc411da715d910cca87c (patch)
tree6dccfda943dda491c379ef14bcd7f7a01306f3b5
parente4b50e14c8f72bcbae53809815d5df70d5aec174 (diff)
btrfs: ignore unfragmented file checks in defrag when compression enabled - rebased
Rebased on btrfs-next and retested. Inform should_defrag_range if BTRFS_DEFRAG_RANGE_COMPRESS is set. If so, skip checks for adjacent extents and extent size when deciding whether to defrag, as these can prevent an uncompressed and unfragmented file from being compressed as requested. Signed-off-by: Andrew Mahone <andrew.mahone@gmail.com>
-rw-r--r--fs/btrfs/ioctl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 0e92e5763005..9ec23b93e019 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -832,7 +832,8 @@ static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em)
832} 832}
833 833
834static int should_defrag_range(struct inode *inode, u64 start, int thresh, 834static int should_defrag_range(struct inode *inode, u64 start, int thresh,
835 u64 *last_len, u64 *skip, u64 *defrag_end) 835 u64 *last_len, u64 *skip, u64 *defrag_end,
836 int compress)
836{ 837{
837 struct extent_map *em; 838 struct extent_map *em;
838 int ret = 1; 839 int ret = 1;
@@ -863,7 +864,7 @@ static int should_defrag_range(struct inode *inode, u64 start, int thresh,
863 * we hit a real extent, if it is big or the next extent is not a 864 * we hit a real extent, if it is big or the next extent is not a
864 * real extent, don't bother defragging it 865 * real extent, don't bother defragging it
865 */ 866 */
866 if ((*last_len == 0 || *last_len >= thresh) && 867 if (!compress && (*last_len == 0 || *last_len >= thresh) &&
867 (em->len >= thresh || !next_mergeable)) 868 (em->len >= thresh || !next_mergeable))
868 ret = 0; 869 ret = 0;
869out: 870out:
@@ -1145,7 +1146,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
1145 1146
1146 if (!should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT, 1147 if (!should_defrag_range(inode, (u64)i << PAGE_CACHE_SHIFT,
1147 extent_thresh, &last_len, &skip, 1148 extent_thresh, &last_len, &skip,
1148 &defrag_end)) { 1149 &defrag_end, range->flags &
1150 BTRFS_DEFRAG_RANGE_COMPRESS)) {
1149 unsigned long next; 1151 unsigned long next;
1150 /* 1152 /*
1151 * the should_defrag function tells us how much to skip 1153 * the should_defrag function tells us how much to skip