From 3595d79c63e0d459342cd6714c025b5fbd78f662 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Mon, 6 Aug 2012 13:46:38 -0600 Subject: [PATCH] --- yaml --- r: 322363 b: refs/heads/master c: 6fc823b10f333313deb0b5d9069cbfd3a3f99f3a h: refs/heads/master i: 322361: 0e2359e161688b31496df58c5adcfdefe9cda1cf 322359: a5661289f69b8bf883d98ab3ad533bb353194413 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/extent-tree.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index ba39bc2c34e2..cf9972f4ea4e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 66657b318e0e443ada229fccd40c8be86cfebdbf +refs/heads/master: 6fc823b10f333313deb0b5d9069cbfd3a3f99f3a diff --git a/trunk/fs/btrfs/extent-tree.c b/trunk/fs/btrfs/extent-tree.c index d3df65f83b5c..1bb408f737fb 100644 --- a/trunk/fs/btrfs/extent-tree.c +++ b/trunk/fs/btrfs/extent-tree.c @@ -2975,17 +2975,16 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group, } spin_unlock(&block_group->lock); - num_pages = (int)div64_u64(block_group->key.offset, 1024 * 1024 * 1024); + /* + * Try to preallocate enough space based on how big the block group is. + * Keep in mind this has to include any pinned space which could end up + * taking up quite a bit since it's not folded into the other space + * cache. + */ + num_pages = (int)div64_u64(block_group->key.offset, 256 * 1024 * 1024); if (!num_pages) num_pages = 1; - /* - * Just to make absolutely sure we have enough space, we're going to - * preallocate 12 pages worth of space for each block group. In - * practice we ought to use at most 8, but we need extra space so we can - * add our header and have a terminator between the extents and the - * bitmaps. - */ num_pages *= 16; num_pages *= PAGE_CACHE_SIZE;