mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
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: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
c65ca98f9e
commit
ee0d904fd9
@ -4107,7 +4107,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
|
||||
struct btrfs_block_rsv block_rsv;
|
||||
u64 root_flags;
|
||||
int ret;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* 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)
|
||||
|
||||
down_write(&fs_info->subvol_sem);
|
||||
|
||||
err = may_destroy_subvol(dest);
|
||||
if (err)
|
||||
ret = may_destroy_subvol(dest);
|
||||
if (ret)
|
||||
goto out_up_write;
|
||||
|
||||
btrfs_init_block_rsv(&block_rsv, BTRFS_BLOCK_RSV_TEMP);
|
||||
@ -4139,13 +4138,13 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
|
||||
* two for dir entries,
|
||||
* two for root ref/backref.
|
||||
*/
|
||||
err = btrfs_subvolume_reserve_metadata(root, &block_rsv, 5, true);
|
||||
if (err)
|
||||
ret = btrfs_subvolume_reserve_metadata(root, &block_rsv, 5, true);
|
||||
if (ret)
|
||||
goto out_up_write;
|
||||
|
||||
trans = btrfs_start_transaction(root, 0);
|
||||
if (IS_ERR(trans)) {
|
||||
err = PTR_ERR(trans);
|
||||
ret = PTR_ERR(trans);
|
||||
goto out_release;
|
||||
}
|
||||
trans->block_rsv = &block_rsv;
|
||||
@ -4155,7 +4154,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
|
||||
|
||||
ret = btrfs_unlink_subvol(trans, dir, dentry);
|
||||
if (ret) {
|
||||
err = ret;
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
goto out_end_trans;
|
||||
}
|
||||
@ -4173,7 +4171,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
|
||||
dest->root_key.objectid);
|
||||
if (ret) {
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
err = ret;
|
||||
goto out_end_trans;
|
||||
}
|
||||
}
|
||||
@ -4183,7 +4180,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
|
||||
dest->root_key.objectid);
|
||||
if (ret && ret != -ENOENT) {
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
err = ret;
|
||||
goto out_end_trans;
|
||||
}
|
||||
if (!btrfs_is_empty_uuid(dest->root_item.received_uuid)) {
|
||||
@ -4193,7 +4189,6 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
|
||||
dest->root_key.objectid);
|
||||
if (ret && ret != -ENOENT) {
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
err = ret;
|
||||
goto out_end_trans;
|
||||
}
|
||||
}
|
||||
@ -4204,14 +4199,12 @@ out_end_trans:
|
||||
trans->block_rsv = NULL;
|
||||
trans->bytes_reserved = 0;
|
||||
ret = btrfs_end_transaction(trans);
|
||||
if (ret && !err)
|
||||
err = ret;
|
||||
inode->i_flags |= S_DEAD;
|
||||
out_release:
|
||||
btrfs_subvolume_release_metadata(root, &block_rsv);
|
||||
out_up_write:
|
||||
up_write(&fs_info->subvol_sem);
|
||||
if (err) {
|
||||
if (ret) {
|
||||
spin_lock(&dest->root_item_lock);
|
||||
root_flags = btrfs_root_flags(&dest->root_item);
|
||||
btrfs_set_root_flags(&dest->root_item,
|
||||
@ -4229,7 +4222,7 @@ out_up_write:
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
|
Loading…
Reference in New Issue
Block a user