From: Chris Mason Date: Tue, 9 Jun 2009 22:35:15 +0000 (-0400) Subject: Btrfs: avoid allocation clusters that are too spread out X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=c604480171c510c1beeb81b82418e5bc4de8f1ae;p=openwrt%2Fstaging%2Fblogic.git Btrfs: avoid allocation clusters that are too spread out In SSD mode for data, and all the time for metadata the allocator will try to find a cluster of nearby blocks for allocations. This commit adds extra checks to make sure that each free block in the cluster is close to the last one. Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 280165581c57..ac23476beb6e 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -645,7 +645,8 @@ again: * we haven't filled the empty size and the window is * very large. reset and try again */ - if (next->offset - window_start > (bytes + empty_size) * 2) { + if (next->offset - (last->offset + last->bytes) > 128 * 1024 || + next->offset - window_start > (bytes + empty_size) * 2) { entry = next; window_start = entry->offset; window_free = entry->bytes;