Commit 425d8315 authored by Alexandre Oliva's avatar Alexandre Oliva Committed by Chris Mason

Btrfs: skip block groups without enough space for a cluster

We test whether a block group has enough free space to hold the
requested block, but when we're doing clustered allocation, we can
save some cycles by testing whether it has enough room for the cluster
upfront, otherwise we end up attempting to set up a cluster and
failing.  Only in the NO_EMPTY_SIZE loop do we attempt an unclustered
allocation, and by then we'll have zeroed the cluster size, so this
patch won't stop us from using the block group as a last resort.
Signed-off-by: default avatarAlexandre Oliva <oliva@lsd.ic.unicamp.br>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 1b22bad7
...@@ -5278,7 +5278,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, ...@@ -5278,7 +5278,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
spin_lock(&block_group->free_space_ctl->tree_lock); spin_lock(&block_group->free_space_ctl->tree_lock);
if (cached && if (cached &&
block_group->free_space_ctl->free_space < block_group->free_space_ctl->free_space <
num_bytes + empty_size) { num_bytes + empty_cluster + empty_size) {
spin_unlock(&block_group->free_space_ctl->tree_lock); spin_unlock(&block_group->free_space_ctl->tree_lock);
goto loop; goto loop;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment