All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 1/5] btrfs: simplify the send_in_progress check in btrfs_delete_subvolume()
Date: Sat, 4 Aug 2018 21:10:53 +0800	[thread overview]
Message-ID: <20180804131057.9967-2-lufq.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <20180804131057.9967-1-lufq.fnst@cn.fujitsu.com>

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 <lufq.fnst@cn.fujitsu.com>
---
 fs/btrfs/inode.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3f51ddc18f98..a7d9691a681f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4287,18 +4287,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);
 
-- 
2.18.0




  reply	other threads:[~2018-08-04 15:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 13:10 [PATCH 0/5] some trivial cleanup about btrfs_delete_subvolume Lu Fengqi
2018-08-04 13:10 ` Lu Fengqi [this message]
2018-08-07 16:03   ` [PATCH 1/5] btrfs: simplify the send_in_progress check in btrfs_delete_subvolume() David Sterba
2018-08-04 13:10 ` [PATCH 2/5] btrfs: use a separate variable to store the num_bytes of the qgroup_reserve Lu Fengqi
2018-08-04 13:54   ` [PATCH v2 " Lu Fengqi
2018-08-07 16:19   ` [PATCH " David Sterba
2018-08-08  3:04     ` Lu Fengqi
2018-08-08 13:56       ` David Sterba
2018-08-08 14:33         ` Lu Fengqi
2018-08-08  3:48     ` Gu, Jinxiang
2018-08-04 13:10 ` [PATCH 3/5] btrfs: switch update_size to bool in both of btrfs_block_rsv_migrate and btrfs_rsv_add_bytes Lu Fengqi
2018-08-07 16:02   ` David Sterba
2018-08-04 13:10 ` [PATCH 4/5] btrfs: remove a useless return statement in btrfs_block_rsv_add Lu Fengqi
2018-08-17 13:29   ` David Sterba
2018-08-04 13:10 ` [PATCH 5/5] btrfs: Remove root parameter from btrfs_insert_dir_item Lu Fengqi
2018-08-07 16:01   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180804131057.9967-2-lufq.fnst@cn.fujitsu.com \
    --to=lufq.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.