aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-03-18 16:16:21 -0400
committerJosef Bacik <josef@redhat.com>2011-03-21 10:26:03 -0400
commit32cb0840ce8e13901fe71a9a8e834a531802ffc4 (patch)
tree397b22d872a7074fc64b13b507354ce248eb298e /fs
parentd0a365e84a886ce6b5b7f7a76be0bb24934ec8f0 (diff)
Btrfs: don't be as aggressive about using bitmaps
We have been creating bitmaps for small extents unconditionally forever. This was great when testing to make sure the bitmap stuff was working, but is overkill normally. So instead of always adding small chunks of free space to bitmaps, only start doing it if we go past half of our extent threshold. This will keeps us from creating a bitmap for just one small free extent at the front of the block group, and will make the allocator a little faster as a result. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/free-space-cache.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 63776ae72f9e..4ab35ea0443f 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1287,9 +1287,22 @@ static int insert_into_bitmap(struct btrfs_block_group_cache *block_group,
1287 * If we are below the extents threshold then we can add this as an 1287 * If we are below the extents threshold then we can add this as an
1288 * extent, and don't have to deal with the bitmap 1288 * extent, and don't have to deal with the bitmap
1289 */ 1289 */
1290 if (block_group->free_extents < block_group->extents_thresh && 1290 if (block_group->free_extents < block_group->extents_thresh) {
1291 info->bytes > block_group->sectorsize * 4) 1291 /*
1292 return 0; 1292 * If this block group has some small extents we don't want to
1293 * use up all of our free slots in the cache with them, we want
1294 * to reserve them to larger extents, however if we have plent
1295 * of cache left then go ahead an dadd them, no sense in adding
1296 * the overhead of a bitmap if we don't have to.
1297 */
1298 if (info->bytes <= block_group->sectorsize * 4) {
1299 if (block_group->free_extents * 2 <=
1300 block_group->extents_thresh)
1301 return 0;
1302 } else {
1303 return 0;
1304 }
1305 }
1293 1306
1294 /* 1307 /*
1295 * some block groups are so tiny they can't be enveloped by a bitmap, so 1308 * some block groups are so tiny they can't be enveloped by a bitmap, so