Commit ee0d904f authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: remove err variable from btrfs_delete_subvolume

Use only a single 'ret' to control whether we should abort the
transaction or not. That's fine, because if we abort a transaction then
btrfs_end_transaction will return the same value as passed to
btrfs_abort_transaction. No semantic changes.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c65ca98f
...@@ -4107,7 +4107,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4107,7 +4107,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
struct btrfs_block_rsv block_rsv; struct btrfs_block_rsv block_rsv;
u64 root_flags; u64 root_flags;
int ret; int ret;
int err;
/* /*
* Don't allow to delete a subvolume with send in progress. This is * Don't allow to delete a subvolume with send in progress. This is
...@@ -4129,8 +4128,8 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4129,8 +4128,8 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
down_write(&fs_info->subvol_sem); down_write(&fs_info->subvol_sem);
err = may_destroy_subvol(dest); ret = may_destroy_subvol(dest);
if (err) if (ret)
goto out_up_write; goto out_up_write;
btrfs_init_block_rsv(&block_rsv, BTRFS_BLOCK_RSV_TEMP); btrfs_init_block_rsv(&block_rsv, BTRFS_BLOCK_RSV_TEMP);
...@@ -4139,13 +4138,13 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4139,13 +4138,13 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
* two for dir entries, * two for dir entries,
* two for root ref/backref. * two for root ref/backref.
*/ */
err = btrfs_subvolume_reserve_metadata(root, &block_rsv, 5, true); ret = btrfs_subvolume_reserve_metadata(root, &block_rsv, 5, true);
if (err) if (ret)
goto out_up_write; goto out_up_write;
trans = btrfs_start_transaction(root, 0); trans = btrfs_start_transaction(root, 0);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
err = PTR_ERR(trans); ret = PTR_ERR(trans);
goto out_release; goto out_release;
} }
trans->block_rsv = &block_rsv; trans->block_rsv = &block_rsv;
...@@ -4155,7 +4154,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4155,7 +4154,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
ret = btrfs_unlink_subvol(trans, dir, dentry); ret = btrfs_unlink_subvol(trans, dir, dentry);
if (ret) { if (ret) {
err = ret;
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_end_trans; goto out_end_trans;
} }
...@@ -4173,7 +4171,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4173,7 +4171,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
dest->root_key.objectid); dest->root_key.objectid);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
err = ret;
goto out_end_trans; goto out_end_trans;
} }
} }
...@@ -4183,7 +4180,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4183,7 +4180,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
dest->root_key.objectid); dest->root_key.objectid);
if (ret && ret != -ENOENT) { if (ret && ret != -ENOENT) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
err = ret;
goto out_end_trans; goto out_end_trans;
} }
if (!btrfs_is_empty_uuid(dest->root_item.received_uuid)) { if (!btrfs_is_empty_uuid(dest->root_item.received_uuid)) {
...@@ -4193,7 +4189,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4193,7 +4189,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
dest->root_key.objectid); dest->root_key.objectid);
if (ret && ret != -ENOENT) { if (ret && ret != -ENOENT) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
err = ret;
goto out_end_trans; goto out_end_trans;
} }
} }
...@@ -4204,14 +4199,12 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4204,14 +4199,12 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
trans->block_rsv = NULL; trans->block_rsv = NULL;
trans->bytes_reserved = 0; trans->bytes_reserved = 0;
ret = btrfs_end_transaction(trans); ret = btrfs_end_transaction(trans);
if (ret && !err)
err = ret;
inode->i_flags |= S_DEAD; inode->i_flags |= S_DEAD;
out_release: out_release:
btrfs_subvolume_release_metadata(root, &block_rsv); btrfs_subvolume_release_metadata(root, &block_rsv);
out_up_write: out_up_write:
up_write(&fs_info->subvol_sem); up_write(&fs_info->subvol_sem);
if (err) { if (ret) {
spin_lock(&dest->root_item_lock); spin_lock(&dest->root_item_lock);
root_flags = btrfs_root_flags(&dest->root_item); root_flags = btrfs_root_flags(&dest->root_item);
btrfs_set_root_flags(&dest->root_item, btrfs_set_root_flags(&dest->root_item,
...@@ -4229,7 +4222,7 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) ...@@ -4229,7 +4222,7 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
} }
} }
return err; return ret;
} }
static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment