Commit c604480171c510c1beeb81b82418e5bc4de8f1ae

Authored by Chris Mason
1 parent 3b30c22f64

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 <chris.mason@oracle.com>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

fs/btrfs/free-space-cache.c
... ... @@ -645,7 +645,8 @@
645 645 * we haven't filled the empty size and the window is
646 646 * very large. reset and try again
647 647 */
648   - if (next->offset - window_start > (bytes + empty_size) * 2) {
  648 + if (next->offset - (last->offset + last->bytes) > 128 * 1024 ||
  649 + next->offset - window_start > (bytes + empty_size) * 2) {
649 650 entry = next;
650 651 window_start = entry->offset;
651 652 window_free = entry->bytes;