Btrfs: sysfs: add support to show replacing target in the sysfs
authorAnand Jain <anand.jain@oracle.com>
Mon, 9 Mar 2015 22:38:42 +0000 (06:38 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 19 Jun 2015 12:03:54 +0000 (14:03 +0200)
This patch will add support to show the replacing target in sysfs
during the process of replacement.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
fs/btrfs/dev-replace.c
fs/btrfs/volumes.c

index f982ef303f1c38529f72fb7c915f184de74c9379..862fbc206755511a6bd3a02eeaa525e992c545bc 100644 (file)
@@ -376,6 +376,10 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
        WARN_ON(!tgt_device);
        dev_replace->tgtdev = tgt_device;
 
+       ret = btrfs_kobj_add_device(tgt_device->fs_devices, tgt_device);
+       if (ret)
+               btrfs_error(root->fs_info, ret, "kobj add dev failed");
+
        printk_in_rcu(KERN_INFO
                      "BTRFS: dev_replace from %s (devid %llu) to %s started\n",
                      src_device->missing ? "<missing disk>" :
@@ -584,7 +588,6 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 
        /* replace the sysfs entry */
        btrfs_kobj_rm_device(fs_info->fs_devices, src_device);
-       btrfs_kobj_add_device(fs_info->fs_devices, tgt_device);
        btrfs_rm_dev_replace_free_srcdev(fs_info, src_device);
 
        /* write back the superblocks */
index ea293db89cc40e30222ff26e8fc881a8819128d1..2d9061f078ca99d2a9dab78683effd28dd58602a 100644 (file)
@@ -1940,6 +1940,9 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
        mutex_lock(&uuid_mutex);
        WARN_ON(!tgtdev);
        mutex_lock(&fs_info->fs_devices->device_list_mutex);
+
+       btrfs_kobj_rm_device(fs_info->fs_devices, tgtdev);
+
        if (tgtdev->bdev) {
                btrfs_scratch_superblock(tgtdev);
                fs_info->fs_devices->open_devices--;