Skip to content

Commit

Permalink
btrfs: reloc: clean dirty subvols if we fail to start a transaction
Browse files Browse the repository at this point in the history
If we do merge_reloc_roots() we could insert a few roots onto the dirty
subvol roots list, where we hold a ref on them.  If we fail to start the
transaction we need to run clean_dirty_subvols() in order to cleanup the
refs.

CC: stable@vger.kernel.org # 5.4+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
josefbacik authored and kdave committed Mar 23, 2020
1 parent fb2d83e commit 6217b0f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -4082,10 +4082,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
goto out_free;
}
btrfs_commit_transaction(trans);
out_free:
ret = clean_dirty_subvols(rc);
if (ret < 0 && !err)
err = ret;
out_free:
btrfs_free_block_rsv(fs_info, rc->block_rsv);
btrfs_free_path(path);
return err;
Expand Down Expand Up @@ -4501,10 +4501,10 @@ int btrfs_recover_relocation(struct btrfs_root *root)
trans = btrfs_join_transaction(rc->extent_root);
if (IS_ERR(trans)) {
err = PTR_ERR(trans);
goto out_free;
goto out_clean;
}
err = btrfs_commit_transaction(trans);

out_clean:
ret = clean_dirty_subvols(rc);
if (ret < 0 && !err)
err = ret;
Expand Down

0 comments on commit 6217b0f

Please sign in to comment.