aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-02-12 14:07:51 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:55 -0500
commitdde5740fdd6175fc95aecf4ccc7856fbbad9b44e (patch)
tree19d3c394b5d8268fee1984b53fa68f170acf013c /fs/btrfs/free-space-cache.c
parent3e39cea61c4ecb5774c08f3e30507fdd58c1cca9 (diff)
Btrfs: relax the block group size limit for bitmaps
Dave pointed out that xfstests 273 will tell you that it failed to load the space cache for a block group when it remounts. This is because we run out of space writing out the block group cache. This is ok and is working as it should, but let's try to be a bit nicer. This happens because the block group was 100mb, but bitmap entries cover 128mb, so we were only getting extent entries for this block group, which ended up being too many to fit in the free space cache. So relax the bitmap size requirements to block groups that are at least half the size a bitmap will cover or larger, that way we can still keep the amount of space used in the free space cache low enough to be able to write it out. With this patch I no longer fail to write out the free space cache. Thanks, Reported-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r--fs/btrfs/free-space-cache.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 0be7a8742a43..c8090f18c217 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1356,6 +1356,8 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl)
1356 u64 bytes_per_bg = BITS_PER_BITMAP * ctl->unit; 1356 u64 bytes_per_bg = BITS_PER_BITMAP * ctl->unit;
1357 int max_bitmaps = div64_u64(size + bytes_per_bg - 1, bytes_per_bg); 1357 int max_bitmaps = div64_u64(size + bytes_per_bg - 1, bytes_per_bg);
1358 1358
1359 max_bitmaps = max(max_bitmaps, 1);
1360
1359 BUG_ON(ctl->total_bitmaps > max_bitmaps); 1361 BUG_ON(ctl->total_bitmaps > max_bitmaps);
1360 1362
1361 /* 1363 /*
@@ -1636,10 +1638,14 @@ static bool use_bitmap(struct btrfs_free_space_ctl *ctl,
1636 } 1638 }
1637 1639
1638 /* 1640 /*
1639 * some block groups are so tiny they can't be enveloped by a bitmap, so 1641 * The original block groups from mkfs can be really small, like 8
1640 * don't even bother to create a bitmap for this 1642 * megabytes, so don't bother with a bitmap for those entries. However
1643 * some block groups can be smaller than what a bitmap would cover but
1644 * are still large enough that they could overflow the 32k memory limit,
1645 * so allow those block groups to still be allowed to have a bitmap
1646 * entry.
1641 */ 1647 */
1642 if (BITS_PER_BITMAP * ctl->unit > block_group->key.offset) 1648 if (((BITS_PER_BITMAP * ctl->unit) >> 1) > block_group->key.offset)
1643 return false; 1649 return false;
1644 1650
1645 return true; 1651 return true;