btrfs: unfold transaction abort at clone_copy_inline_extent()

We have a common error path where we abort the transaction, but like this
in case we get a transaction abort stack trace we don't know exactly which
previous function call failed. Instead abort the transaction after any
function call that returns an error, so that we can easily identify which
function failed.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana
2025-05-16 19:37:44 +01:00
committed by David Sterba
parent 5ff6050fcd
commit f2de2b9ffd

View File

@@ -268,11 +268,15 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,
drop_args.end = aligned_end;
drop_args.drop_cache = true;
ret = btrfs_drop_extents(trans, root, inode, &drop_args);
if (ret)
if (ret) {
btrfs_abort_transaction(trans, ret);
goto out;
}
ret = btrfs_insert_empty_item(trans, root, path, new_key, size);
if (ret)
if (ret) {
btrfs_abort_transaction(trans, ret);
goto out;
}
write_extent_buffer(path->nodes[0], inline_data,
btrfs_item_ptr_offset(path->nodes[0],
@@ -281,6 +285,8 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,
btrfs_update_inode_bytes(inode, datal, drop_args.bytes_found);
btrfs_set_inode_full_sync(inode);
ret = btrfs_inode_set_file_extent_range(inode, 0, aligned_end);
if (ret)
btrfs_abort_transaction(trans, ret);
out:
if (!ret && !trans) {
/*
@@ -295,10 +301,8 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,
trans = NULL;
}
}
if (ret && trans) {
btrfs_abort_transaction(trans, ret);
if (ret && trans)
btrfs_end_transaction(trans);
}
if (!ret)
*trans_out = trans;