aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-03-18 15:13:42 -0400
committerJosef Bacik <josef@redhat.com>2011-03-21 10:25:48 -0400
commit7d0d2e8e6b6f7da221a25238cf490a095c8c4788 (patch)
treea2bce1c429f9efb9d3cc41390afa73839787c96c /fs/btrfs
parent22a94d44bd6876a90630338229da6c0436d46593 (diff)
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: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/free-space-cache.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 0282033041e1..f631df870f64 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1999,6 +1999,16 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans,
1999 min_bytes = max(bytes, (bytes + empty_size) >> 2); 1999 min_bytes = max(bytes, (bytes + empty_size) >> 2);
2000 2000
2001 spin_lock(&block_group->tree_lock); 2001 spin_lock(&block_group->tree_lock);
2002
2003 /*
2004 * If we know we don't have enough space to make a cluster don't even
2005 * bother doing all the work to try and find one.
2006 */
2007 if (block_group->free_space < min_bytes) {
2008 spin_unlock(&block_group->tree_lock);
2009 return -ENOSPC;
2010 }
2011
2002 spin_lock(&cluster->lock); 2012 spin_lock(&cluster->lock);
2003 2013
2004 /* someone already found a cluster, hooray */ 2014 /* someone already found a cluster, hooray */