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

From: Ben Hutchings
Date: Sun Oct 14 2018 - 11:49:36 EST


3.16.60-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Nikolay Borisov <nborisov@xxxxxxxx>

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@xxxxxxxx>
Reviewed-by: David Sterba <dsterba@xxxxxxxx>
Signed-off-by: David Sterba <dsterba@xxxxxxxx>
[bwh: Backported to 3.16:
- btrfs_{abort,end}_transaction() take a pointer to btrfs_root
- Adjust context]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
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);