From 7a30715130035cc976148197f55dae1ac49965fb Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 12 Feb 2013 14:07:51 -0500 Subject: [PATCH] --- yaml --- r: 360453 b: refs/heads/master c: dde5740fdd6175fc95aecf4ccc7856fbbad9b44e h: refs/heads/master i: 360451: fb37a3d4e98ae9b65ece445fc1c149919c63b838 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/free-space-cache.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 5bcf983560ad..6d5870396543 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3e39cea61c4ecb5774c08f3e30507fdd58c1cca9 +refs/heads/master: dde5740fdd6175fc95aecf4ccc7856fbbad9b44e diff --git a/trunk/fs/btrfs/free-space-cache.c b/trunk/fs/btrfs/free-space-cache.c index 0be7a8742a43..c8090f18c217 100644 --- a/trunk/fs/btrfs/free-space-cache.c +++ b/trunk/fs/btrfs/free-space-cache.c @@ -1356,6 +1356,8 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) u64 bytes_per_bg = BITS_PER_BITMAP * ctl->unit; int max_bitmaps = div64_u64(size + bytes_per_bg - 1, bytes_per_bg); + max_bitmaps = max(max_bitmaps, 1); + BUG_ON(ctl->total_bitmaps > max_bitmaps); /* @@ -1636,10 +1638,14 @@ static bool use_bitmap(struct btrfs_free_space_ctl *ctl, } /* - * some block groups are so tiny they can't be enveloped by a bitmap, so - * don't even bother to create a bitmap for this + * The original block groups from mkfs can be really small, like 8 + * megabytes, so don't bother with a bitmap for those entries. However + * some block groups can be smaller than what a bitmap would cover but + * are still large enough that they could overflow the 32k memory limit, + * so allow those block groups to still be allowed to have a bitmap + * entry. */ - if (BITS_PER_BITMAP * ctl->unit > block_group->key.offset) + if (((BITS_PER_BITMAP * ctl->unit) >> 1) > block_group->key.offset) return false; return true;