Commit 7d0d2e8e authored by Josef Bacik's avatar Josef Bacik

Btrfs: check free space in block group before searching for a cluster

The free space cluster stuff is heavy duty, so there is no sense in going
through the entire song and dance if there isn't enough space in the block group
to begin with.  Thanks,
Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
parent 22a94d44
...@@ -1999,6 +1999,16 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, ...@@ -1999,6 +1999,16 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans,
min_bytes = max(bytes, (bytes + empty_size) >> 2); min_bytes = max(bytes, (bytes + empty_size) >> 2);
spin_lock(&block_group->tree_lock); spin_lock(&block_group->tree_lock);
/*
* If we know we don't have enough space to make a cluster don't even
* bother doing all the work to try and find one.
*/
if (block_group->free_space < min_bytes) {
spin_unlock(&block_group->tree_lock);
return -ENOSPC;
}
spin_lock(&cluster->lock); spin_lock(&cluster->lock);
/* someone already found a cluster, hooray */ /* someone already found a cluster, hooray */
......
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