Skip to content

Commit 9b8fda7

Browse files
josefbacikgregkh
authored andcommitted
btrfs: unset reloc control if we fail to recover
commit fb2d83e upstream. 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: [email protected] # 5.4+ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4965675 commit 9b8fda7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/btrfs/relocation.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,9 +4593,8 @@ int btrfs_recover_relocation(struct btrfs_root *root)
45934593

45944594
trans = btrfs_join_transaction(rc->extent_root);
45954595
if (IS_ERR(trans)) {
4596-
unset_reloc_control(rc);
45974596
err = PTR_ERR(trans);
4598-
goto out_free;
4597+
goto out_unset;
45994598
}
46004599

46014600
rc->merge_reloc_tree = 1;
@@ -4615,7 +4614,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
46154614
if (IS_ERR(fs_root)) {
46164615
err = PTR_ERR(fs_root);
46174616
list_add_tail(&reloc_root->root_list, &reloc_roots);
4618-
goto out_free;
4617+
goto out_unset;
46194618
}
46204619

46214620
err = __add_reloc_root(reloc_root);
@@ -4625,7 +4624,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
46254624

46264625
err = btrfs_commit_transaction(trans);
46274626
if (err)
4628-
goto out_free;
4627+
goto out_unset;
46294628

46304629
merge_reloc_roots(rc);
46314630

@@ -4641,7 +4640,8 @@ int btrfs_recover_relocation(struct btrfs_root *root)
46414640
ret = clean_dirty_subvols(rc);
46424641
if (ret < 0 && !err)
46434642
err = ret;
4644-
out_free:
4643+
out_unset:
4644+
unset_reloc_control(rc);
46454645
kfree(rc);
46464646
out:
46474647
if (!list_empty(&reloc_roots))

0 commit comments

Comments
 (0)