summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason2014-08-26 22:55:54 +0200
committerChris Mason2014-08-27 17:45:37 +0200
commite9512d72e8e61c750c90efacd720abe3c4569822 (patch)
treebaf130dd52f12cdf4a5f9e0ef18514aa710009e1
parentBtrfs: fix task hang under heavy compressed write (diff)
downloadkernel-qcow2-linux-e9512d72e8e61c750c90efacd720abe3c4569822.tar.gz
kernel-qcow2-linux-e9512d72e8e61c750c90efacd720abe3c4569822.tar.xz
kernel-qcow2-linux-e9512d72e8e61c750c90efacd720abe3c4569822.zip
Btrfs: fix autodefrag with compression
The autodefrag code skips defrag when two extents are adjacent. But one big advantage for autodefrag is cutting down on the number of small extents, even when they are adjacent. This commit changes it to defrag all small extents. Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/ioctl.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index fce6fd0e3f50..a018ea484d39 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1019,8 +1019,10 @@ static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em)
return false;
next = defrag_lookup_extent(inode, em->start + em->len);
- if (!next || next->block_start >= EXTENT_MAP_LAST_BYTE ||
- (em->block_start + em->block_len == next->block_start))
+ if (!next || next->block_start >= EXTENT_MAP_LAST_BYTE)
+ ret = false;
+ else if ((em->block_start + em->block_len == next->block_start) &&
+ (em->block_len > 128 * 1024 && next->block_len > 128 * 1024))
ret = false;
free_extent_map(next);
@@ -1055,7 +1057,6 @@ static int should_defrag_range(struct inode *inode, u64 start, int thresh,
}
next_mergeable = defrag_check_next_extent(inode, em);
-
/*
* we hit a real extent, if it is big or the next extent is not a
* real extent, don't bother defragging it