linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()
Date: Tue, 17 Oct 2017 06:53:50 +0800	[thread overview]
Message-ID: <20171016225350.15463-1-anand.jain@oracle.com> (raw)
In-Reply-To: <20171016144547.GR3521@twin.jikos.cz>

Use ASSERT instead of BUG_ON.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
V2: Accepts David suggestion to keep the check as ASSERT.
    Adds more comments to explain the context.

 fs/btrfs/volumes.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 93afc7d49d4d..94a9e69e844b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2015,19 +2015,20 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info,
 	}
 
 	btrfs_close_bdev(srcdev);
-
 	call_rcu(&srcdev->rcu, free_device);
 
-	/*
-	 * unless fs_devices is seed fs, num_devices shouldn't go
-	 * zero
-	 */
-	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);
-
 	/* if this is no devs we rather delete the fs_devices */
 	if (!fs_devices->num_devices) {
 		struct btrfs_fs_devices *tmp_fs_devices;
 
+		/*
+		 * In a mounted FS, num_devices can't be zero unless
+		 * its a seed. Where in case of seed device being replaced,
+		 * the replace target added to the sprout FS, so there
+		 * will be no more device left under the seed FS.
+		 */
+		ASSERT(fs_devices->seeding);
+
 		tmp_fs_devices = fs_info->fs_devices;
 		while (tmp_fs_devices) {
 			if (tmp_fs_devices->seed == fs_devices) {
-- 
2.13.1


  reply	other threads:[~2017-10-16 22:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12  9:00 [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev() Anand Jain
2017-10-16 14:45 ` David Sterba
2017-10-16 22:53   ` Anand Jain [this message]
2017-10-16 23:32   ` Anand Jain

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=20171016225350.15463-1-anand.jain@oracle.com \
    --to=anand.jain@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).