From: Lu Fengqi Date: Sat, 4 Aug 2018 13:10:53 +0000 (+0800) Subject: btrfs: simplify the send_in_progress check in btrfs_delete_subvolume X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a7176f74fa570c83a48e66435b77651ad8fc5aee;p=linux.git btrfs: simplify the send_in_progress check in btrfs_delete_subvolume Only when send_in_progress, we have to do something different such as btrfs_warn() and return -EPERM. Therefore, we could check send_in_progress first and process error handling, after the root_item_lock has been got. Just for better readability. No functional change. Signed-off-by: Lu Fengqi Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3ea5339603cff..8b3d719e229de 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4270,18 +4270,17 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) * again is not run concurrently. */ spin_lock(&dest->root_item_lock); - root_flags = btrfs_root_flags(&dest->root_item); - if (dest->send_in_progress == 0) { - btrfs_set_root_flags(&dest->root_item, - root_flags | BTRFS_ROOT_SUBVOL_DEAD); - spin_unlock(&dest->root_item_lock); - } else { + if (dest->send_in_progress) { spin_unlock(&dest->root_item_lock); btrfs_warn(fs_info, "attempt to delete subvolume %llu during send", dest->root_key.objectid); return -EPERM; } + root_flags = btrfs_root_flags(&dest->root_item); + btrfs_set_root_flags(&dest->root_item, + root_flags | BTRFS_ROOT_SUBVOL_DEAD); + spin_unlock(&dest->root_item_lock); down_write(&fs_info->subvol_sem);