summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik2012-12-18 15:16:16 +0100
committerJosef Bacik2013-02-20 15:37:09 +0100
commitc6b305a89b1903d63652691ad5eb9f05aa0326b8 (patch)
tree2b16ef4fb5c23e64ef0d0092674ebfaee3ac54d2 /fs/btrfs/extent-tree.c
parentBtrfs: wait on ordered extents at the last possible moment (diff)
downloadkernel-qcow2-linux-c6b305a89b1903d63652691ad5eb9f05aa0326b8.tar.gz
kernel-qcow2-linux-c6b305a89b1903d63652691ad5eb9f05aa0326b8.tar.xz
kernel-qcow2-linux-c6b305a89b1903d63652691ad5eb9f05aa0326b8.zip
Btrfs: don't re-enter when allocating a chunk
If we start running low on metadata space we will try to allocate a chunk, which could then try to allocate a chunk to add the device entry. The thing is we allocate a chunk before we try really hard to make the allocation, so we should be able to find space for the device entry. Add a flag to the trans handle so we know we're currently allocating a chunk so we can just bail out if we try to allocate another chunk. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d5e60d25ca51..c642fc2cfc2b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3570,6 +3570,10 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
int wait_for_alloc = 0;
int ret = 0;
+ /* Don't re-enter if we're already allocating a chunk */
+ if (trans->allocating_chunk)
+ return -ENOSPC;
+
space_info = __find_space_info(extent_root->fs_info, flags);
if (!space_info) {
ret = update_space_info(extent_root->fs_info, flags,
@@ -3612,6 +3616,8 @@ again:
goto again;
}
+ trans->allocating_chunk = true;
+
/*
* If we have mixed data/metadata chunks we want to make sure we keep
* allocating mixed chunks instead of individual chunks.
@@ -3638,6 +3644,7 @@ again:
check_system_chunk(trans, extent_root, flags);
ret = btrfs_alloc_chunk(trans, extent_root, flags);
+ trans->allocating_chunk = false;
if (ret < 0 && ret != -ENOSPC)
goto out;