[PATCH 3.16 080/366] btrfs: Refactor transaction handling in received subvolume ioctl

Ben Hutchings
2018-10-14T23:30:56Z

From: Nikolay Borisov <nborisov@suse.com>

commit efd38150af45375b46576d0110a323d7fab7e142 upstream.

If btrfs_transaction_commit fails it will proceed to call
cleanup_transaction, which in turn already does btrfs_abort_transaction.
So let's remove the unnecessary code duplication. Also let's be explicit
about handling failure of btrfs_uuid_tree_add by calling
btrfs_end_transaction.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
[bwh: Backported to 3.16:
- btrfs_{abort,end}_transaction() take a pointer to btrfs_root
- Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
fs/btrfs/ioctl.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -5077,15 +5077,11 @@ static long _btrfs_ioctl_set_received_su
root->root_key.objectid);
if (ret < 0 && ret != -EEXIST) {
btrfs_abort_transaction(trans, root, ret);
+ btrfs_end_transaction(trans, root);
goto out;
}
}
ret = btrfs_commit_transaction(trans, root);
- if (ret < 0) {
- btrfs_abort_transaction(trans, root, ret);
- goto out;
- }
-
out:
up_write(&root->fs_info->subvol_sem);
mnt_drop_write_file(file);