diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-11-09 01:48:01 -0500 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2011-01-26 12:04:31 -0500 |
commit | 8eb2d829ffea3677c21bd038f19e5d8ca6b43e36 (patch) | |
tree | fc96e4d61125b703df38ee133a3d031f1c85d4a2 /fs/btrfs/free-space-cache.c | |
parent | 65e5341b9a0c39767ae1fecc727d70eda0dd6d83 (diff) |
btrfs: Fix threshold calculation for block groups smaller than 1GB
If a block group is smaller than 1GB, the extent entry threadhold
calculation will always set the threshold to 0.
So as free space gets fragmented, btrfs will switch to use bitmap
to manage free space, but then will never switch back to extents
due to this bug.
Reviewed-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r-- | fs/btrfs/free-space-cache.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 60d684266959..42f4015988ec 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -1016,14 +1016,18 @@ static void recalculate_thresholds(struct btrfs_block_group_cache *block_group) | |||
1016 | u64 max_bytes; | 1016 | u64 max_bytes; |
1017 | u64 bitmap_bytes; | 1017 | u64 bitmap_bytes; |
1018 | u64 extent_bytes; | 1018 | u64 extent_bytes; |
1019 | u64 size = block_group->key.offset; | ||
1019 | 1020 | ||
1020 | /* | 1021 | /* |
1021 | * The goal is to keep the total amount of memory used per 1gb of space | 1022 | * The goal is to keep the total amount of memory used per 1gb of space |
1022 | * at or below 32k, so we need to adjust how much memory we allow to be | 1023 | * at or below 32k, so we need to adjust how much memory we allow to be |
1023 | * used by extent based free space tracking | 1024 | * used by extent based free space tracking |
1024 | */ | 1025 | */ |
1025 | max_bytes = MAX_CACHE_BYTES_PER_GIG * | 1026 | if (size < 1024 * 1024 * 1024) |
1026 | (div64_u64(block_group->key.offset, 1024 * 1024 * 1024)); | 1027 | max_bytes = MAX_CACHE_BYTES_PER_GIG; |
1028 | else | ||
1029 | max_bytes = MAX_CACHE_BYTES_PER_GIG * | ||
1030 | div64_u64(size, 1024 * 1024 * 1024); | ||
1027 | 1031 | ||
1028 | /* | 1032 | /* |
1029 | * we want to account for 1 more bitmap than what we have so we can make | 1033 | * we want to account for 1 more bitmap than what we have so we can make |