blob: 05ef25ee0c79c682557ff8cff8ddfb8251cb4553 [file] [log] [blame]
From: Nikolay Borisov <nborisov@suse.com>
Date: Thu, 28 Sep 2017 11:45:26 +0300
Subject: btrfs: Refactor transaction handling in received subvolume ioctl
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);