aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-05-13 11:07:12 -0400
committerJosef Bacik <josef@redhat.com>2011-05-23 13:03:15 -0400
commitcca1c81f43e26ab60c0d1090fb90992358d69bdf (patch)
tree8c445c012b9b0184eed9b7f52b35c0d0b85b0e0b
parent026fd317828500524cdc7e5ff9e8e7923abb2868 (diff)
Btrfs: don't try to allocate from a block group that doesn't have enough space
If we have a very large filesystem, we can spend a lot of time in find_free_extent just trying to allocate from empty block groups. So instead check to see if the block group even has enough space for the allocation, and if not go on to the next block group. Signed-off-by: Josef Bacik <josef@redhat.com>
-rw-r--r--fs/btrfs/extent-tree.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1ba2cc58eab5..c8c318494dee 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5159,6 +5159,14 @@ have_block_group:
5159 if (unlikely(block_group->ro)) 5159 if (unlikely(block_group->ro))
5160 goto loop; 5160 goto loop;
5161 5161
5162 spin_lock(&block_group->tree_lock);
5163 if (cached &&
5164 block_group->free_space < num_bytes + empty_size) {
5165 spin_unlock(&block_group->tree_lock);
5166 goto loop;
5167 }
5168 spin_unlock(&block_group->tree_lock);
5169
5162 /* 5170 /*
5163 * Ok we want to try and use the cluster allocator, so lets look 5171 * Ok we want to try and use the cluster allocator, so lets look
5164 * there, unless we are on LOOP_NO_EMPTY_SIZE, since we will 5172 * there, unless we are on LOOP_NO_EMPTY_SIZE, since we will