btrfs: handle btrfs_cow_block errors in replace_path

If we error out COWing the root node when doing a replace_path then we
simply unlock and free the buffer and return the error.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2021-03-12 15:25:22 -05:00 committed by David Sterba
parent 7a9213a935
commit 45b87c5d25
1 changed files with 10 additions and 2 deletions

View File

@ -1231,7 +1231,11 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
if (cow) {
ret = btrfs_cow_block(trans, dest, eb, NULL, 0, &eb,
BTRFS_NESTING_COW);
BUG_ON(ret);
if (ret) {
btrfs_tree_unlock(eb);
free_extent_buffer(eb);
return ret;
}
}
if (next_key) {
@ -1291,7 +1295,11 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
ret = btrfs_cow_block(trans, dest, eb, parent,
slot, &eb,
BTRFS_NESTING_COW);
BUG_ON(ret);
if (ret) {
btrfs_tree_unlock(eb);
free_extent_buffer(eb);
break;
}
}
btrfs_tree_unlock(parent);