@@ -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) {
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(-)