aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2016-05-27 13:08:26 -0400
committerDavid Sterba <dsterba@suse.com>2016-07-07 12:45:53 -0400
commitac2fabac4211431b607b326c2233e73b81e86af2 (patch)
treeae893ce479dfd9ae522322e890ef105fb7acd14a /fs/btrfs
parent40acc3eededbe16f6104a32776e541f223d00b5e (diff)
Btrfs: fill relocation block rsv after allocation
Since we set the reloc control before we've reserved our space for relocation we could race with a root being dirtied and not actually have space to do our init reloc root. So once we've allocated it and set it up go ahead and make our reservation before setting the relocate control, that way anybody who tries to do the reloc root init has space to use. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/relocation.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 0bf3bc879503..23e16de52e23 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3871,6 +3871,7 @@ static noinline_for_stack
3871int prepare_to_relocate(struct reloc_control *rc) 3871int prepare_to_relocate(struct reloc_control *rc)
3872{ 3872{
3873 struct btrfs_trans_handle *trans; 3873 struct btrfs_trans_handle *trans;
3874 int ret;
3874 3875
3875 rc->block_rsv = btrfs_alloc_block_rsv(rc->extent_root, 3876 rc->block_rsv = btrfs_alloc_block_rsv(rc->extent_root,
3876 BTRFS_BLOCK_RSV_TEMP); 3877 BTRFS_BLOCK_RSV_TEMP);
@@ -3885,6 +3886,11 @@ int prepare_to_relocate(struct reloc_control *rc)
3885 rc->reserved_bytes = 0; 3886 rc->reserved_bytes = 0;
3886 rc->block_rsv->size = rc->extent_root->nodesize * 3887 rc->block_rsv->size = rc->extent_root->nodesize *
3887 RELOCATION_RESERVED_NODES; 3888 RELOCATION_RESERVED_NODES;
3889 ret = btrfs_block_rsv_refill(rc->extent_root,
3890 rc->block_rsv, rc->block_rsv->size,
3891 BTRFS_RESERVE_FLUSH_ALL);
3892 if (ret)
3893 return ret;
3888 3894
3889 rc->create_reloc_tree = 1; 3895 rc->create_reloc_tree = 1;
3890 set_reloc_control(rc); 3896 set_reloc_control(rc);