From 76825bef08849b61c523e27f3cda55581ff502d7 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Fri, 18 Mar 2011 16:16:21 -0400 Subject: [PATCH] --- yaml --- r: 243158 b: refs/heads/master c: 32cb0840ce8e13901fe71a9a8e834a531802ffc4 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/btrfs/free-space-cache.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index f862ff20c199..e7ab62731958 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d0a365e84a886ce6b5b7f7a76be0bb24934ec8f0 +refs/heads/master: 32cb0840ce8e13901fe71a9a8e834a531802ffc4 diff --git a/trunk/fs/btrfs/free-space-cache.c b/trunk/fs/btrfs/free-space-cache.c index 63776ae72f9e..4ab35ea0443f 100644 --- a/trunk/fs/btrfs/free-space-cache.c +++ b/trunk/fs/btrfs/free-space-cache.c @@ -1287,9 +1287,22 @@ static int insert_into_bitmap(struct btrfs_block_group_cache *block_group, * If we are below the extents threshold then we can add this as an * extent, and don't have to deal with the bitmap */ - if (block_group->free_extents < block_group->extents_thresh && - info->bytes > block_group->sectorsize * 4) - return 0; + if (block_group->free_extents < block_group->extents_thresh) { + /* + * If this block group has some small extents we don't want to + * use up all of our free slots in the cache with them, we want + * to reserve them to larger extents, however if we have plent + * of cache left then go ahead an dadd them, no sense in adding + * the overhead of a bitmap if we don't have to. + */ + if (info->bytes <= block_group->sectorsize * 4) { + if (block_group->free_extents * 2 <= + block_group->extents_thresh) + return 0; + } else { + return 0; + } + } /* * some block groups are so tiny they can't be enveloped by a bitmap, so