提交 14ed0ca6 编写于 作者: J Josef Bacik

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: NJosef Bacik <josef@redhat.com>
上级 0019f10d
...@@ -3000,8 +3000,7 @@ static void force_metadata_allocation(struct btrfs_fs_info *info) ...@@ -3000,8 +3000,7 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
rcu_read_unlock(); rcu_read_unlock();
} }
static int should_alloc_chunk(struct btrfs_space_info *sinfo, static int should_alloc_chunk(struct btrfs_space_info *sinfo, u64 alloc_bytes)
u64 alloc_bytes)
{ {
u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly; u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly;
...@@ -3013,6 +3012,10 @@ static int should_alloc_chunk(struct btrfs_space_info *sinfo, ...@@ -3013,6 +3012,10 @@ static int should_alloc_chunk(struct btrfs_space_info *sinfo,
alloc_bytes < div_factor(num_bytes, 8)) alloc_bytes < div_factor(num_bytes, 8))
return 0; return 0;
if (num_bytes > 256 * 1024 * 1024 &&
sinfo->bytes_used < div_factor(num_bytes, 3))
return 0;
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册