Btrfs: make the logic of source device removing more clear
authorMiao Xie <miaox@cn.fujitsu.com>
Wed, 3 Sep 2014 13:35:44 +0000 (21:35 +0800)
committerChris Mason <clm@fb.com>
Wed, 17 Sep 2014 20:38:46 +0000 (13:38 -0700)
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/dev-replace.c
fs/btrfs/volumes.c

index e9cbbdb7297867b9692afb96f11a7202992d5c3f..6f662b34ba0e8392c58d7d481092f9e461631af4 100644 (file)
@@ -569,8 +569,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
        if (fs_info->fs_devices->latest_bdev == src_device->bdev)
                fs_info->fs_devices->latest_bdev = tgt_device->bdev;
        list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list);
-       if (src_device->fs_devices->seeding)
-               fs_info->fs_devices->rw_devices++;
+       fs_info->fs_devices->rw_devices++;
 
        /* replace the sysfs entry */
        btrfs_kobj_rm_device(fs_info, src_device);
index a15c8ac5d5b3ad1ac3139aaafb628d029d7bdad2..2e078fa705a6d934d6a14cf33b12c82fbaf39500 100644 (file)
@@ -1819,23 +1819,18 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
        list_del_rcu(&srcdev->dev_list);
        list_del_rcu(&srcdev->dev_alloc_list);
        fs_devices->num_devices--;
-       if (srcdev->missing) {
+       if (srcdev->missing)
                fs_devices->missing_devices--;
-               if (!fs_devices->seeding)
-                       fs_devices->rw_devices++;
+
+       if (srcdev->writeable) {
+               fs_devices->rw_devices--;
+               /* zero out the old super if it is writable */
+               btrfs_scratch_superblock(srcdev);
        }
 
-       if (srcdev->bdev) {
+       if (srcdev->bdev)
                fs_devices->open_devices--;
 
-               /*
-                * zero out the old super if it is not writable
-                * (e.g. seed device)
-                */
-               if (srcdev->writeable)
-                       btrfs_scratch_superblock(srcdev);
-       }
-
        call_rcu(&srcdev->rcu, free_device);
 
        /*