Commit fb2d83ee authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: unset reloc control if we fail to recover

If we fail to load an fs root, or fail to start a transaction we can
bail without unsetting the reloc control, which leads to problems later
when we free the reloc control but still have it attached to the file
system.

In the normal path we'll end up calling unset_reloc_control() twice, but
all it does is set fs_info->reloc_control = NULL, and we can only have
one balance at a time so it's not racey.

CC: stable@vger.kernel.org # 5.4+
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8e19c973
...@@ -4460,9 +4460,8 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4460,9 +4460,8 @@ int btrfs_recover_relocation(struct btrfs_root *root)
trans = btrfs_join_transaction(rc->extent_root); trans = btrfs_join_transaction(rc->extent_root);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
unset_reloc_control(rc);
err = PTR_ERR(trans); err = PTR_ERR(trans);
goto out_free; goto out_unset;
} }
rc->merge_reloc_tree = 1; rc->merge_reloc_tree = 1;
...@@ -4482,7 +4481,7 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4482,7 +4481,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
if (IS_ERR(fs_root)) { if (IS_ERR(fs_root)) {
err = PTR_ERR(fs_root); err = PTR_ERR(fs_root);
list_add_tail(&reloc_root->root_list, &reloc_roots); list_add_tail(&reloc_root->root_list, &reloc_roots);
goto out_free; goto out_unset;
} }
err = __add_reloc_root(reloc_root); err = __add_reloc_root(reloc_root);
...@@ -4493,7 +4492,7 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4493,7 +4492,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
err = btrfs_commit_transaction(trans); err = btrfs_commit_transaction(trans);
if (err) if (err)
goto out_free; goto out_unset;
merge_reloc_roots(rc); merge_reloc_roots(rc);
...@@ -4509,7 +4508,8 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4509,7 +4508,8 @@ int btrfs_recover_relocation(struct btrfs_root *root)
ret = clean_dirty_subvols(rc); ret = clean_dirty_subvols(rc);
if (ret < 0 && !err) if (ret < 0 && !err)
err = ret; err = ret;
out_free: out_unset:
unset_reloc_control(rc);
kfree(rc); kfree(rc);
out: out:
if (!list_empty(&reloc_roots)) if (!list_empty(&reloc_roots))
......
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