diff options
-rw-r--r-- | fs/btrfs/extent-tree.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index d3df65f83b5c..1bb408f737fb 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2975,17 +2975,16 @@ again: | |||
2975 | } | 2975 | } |
2976 | spin_unlock(&block_group->lock); | 2976 | spin_unlock(&block_group->lock); |
2977 | 2977 | ||
2978 | num_pages = (int)div64_u64(block_group->key.offset, 1024 * 1024 * 1024); | 2978 | /* |
2979 | * Try to preallocate enough space based on how big the block group is. | ||
2980 | * Keep in mind this has to include any pinned space which could end up | ||
2981 | * taking up quite a bit since it's not folded into the other space | ||
2982 | * cache. | ||
2983 | */ | ||
2984 | num_pages = (int)div64_u64(block_group->key.offset, 256 * 1024 * 1024); | ||
2979 | if (!num_pages) | 2985 | if (!num_pages) |
2980 | num_pages = 1; | 2986 | num_pages = 1; |
2981 | 2987 | ||
2982 | /* | ||
2983 | * Just to make absolutely sure we have enough space, we're going to | ||
2984 | * preallocate 12 pages worth of space for each block group. In | ||
2985 | * practice we ought to use at most 8, but we need extra space so we can | ||
2986 | * add our header and have a terminator between the extents and the | ||
2987 | * bitmaps. | ||
2988 | */ | ||
2989 | num_pages *= 16; | 2988 | num_pages *= 16; |
2990 | num_pages *= PAGE_CACHE_SIZE; | 2989 | num_pages *= PAGE_CACHE_SIZE; |
2991 | 2990 | ||