diff options
author | Josef Bacik <josef@redhat.com> | 2010-10-15 15:23:48 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2010-10-22 15:55:00 -0400 |
commit | 14ed0ca6e8236f2d264c4a8faec9e3a2b3d04377 (patch) | |
tree | 1477718d4ab61c258c2a514afec5bfc36e89acf7 /fs/btrfs/extent-tree.c | |
parent | 0019f10db6f596f3e14a19f9bd7059a1b85b0853 (diff) |
Btrfs: don't allocate chunks as aggressively
Because the ENOSPC code over reserves super aggressively we end up allocating
chunks way more often than we should. For example with my fs_mark tests on a
2gb fs I can end up reserved 1gb just for metadata, when only 34mb of that is
being used. So instead check to see if the amount of space actually used is
less than 30% of the total space, and if so don't allocate a chunk, but only if
we have at least 256mb of free space to make sure we don't put too much pressure
on free space.
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 2846cebc9427..aca3314ef8b9 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3000,8 +3000,7 @@ static void force_metadata_allocation(struct btrfs_fs_info *info) | |||
3000 | rcu_read_unlock(); | 3000 | rcu_read_unlock(); |
3001 | } | 3001 | } |
3002 | 3002 | ||
3003 | static int should_alloc_chunk(struct btrfs_space_info *sinfo, | 3003 | static int should_alloc_chunk(struct btrfs_space_info *sinfo, u64 alloc_bytes) |
3004 | u64 alloc_bytes) | ||
3005 | { | 3004 | { |
3006 | u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly; | 3005 | u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly; |
3007 | 3006 | ||
@@ -3013,6 +3012,10 @@ static int should_alloc_chunk(struct btrfs_space_info *sinfo, | |||
3013 | alloc_bytes < div_factor(num_bytes, 8)) | 3012 | alloc_bytes < div_factor(num_bytes, 8)) |
3014 | return 0; | 3013 | return 0; |
3015 | 3014 | ||
3015 | if (num_bytes > 256 * 1024 * 1024 && | ||
3016 | sinfo->bytes_used < div_factor(num_bytes, 3)) | ||
3017 | return 0; | ||
3018 | |||
3016 | return 1; | 3019 | return 1; |
3017 | } | 3020 | } |
3018 | 3021 | ||