diff options
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r-- | fs/btrfs/dev-replace.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 0bf41f8b1e23..ca6a3a3b6b6c 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -417,9 +417,15 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
417 | &dev_replace->scrub_progress, 0, 1); | 417 | &dev_replace->scrub_progress, 0, 1); |
418 | 418 | ||
419 | ret = btrfs_dev_replace_finishing(root->fs_info, ret); | 419 | ret = btrfs_dev_replace_finishing(root->fs_info, ret); |
420 | WARN_ON(ret); | 420 | /* don't warn if EINPROGRESS, someone else might be running scrub */ |
421 | if (ret == -EINPROGRESS) { | ||
422 | args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS; | ||
423 | ret = 0; | ||
424 | } else { | ||
425 | WARN_ON(ret); | ||
426 | } | ||
421 | 427 | ||
422 | return 0; | 428 | return ret; |
423 | 429 | ||
424 | leave: | 430 | leave: |
425 | dev_replace->srcdev = NULL; | 431 | dev_replace->srcdev = NULL; |
@@ -537,7 +543,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
537 | btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); | 543 | btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); |
538 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); | 544 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); |
539 | 545 | ||
540 | return 0; | 546 | return scrub_ret; |
541 | } | 547 | } |
542 | 548 | ||
543 | printk_in_rcu(KERN_INFO | 549 | printk_in_rcu(KERN_INFO |
@@ -566,15 +572,11 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
566 | list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); | 572 | list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); |
567 | fs_info->fs_devices->rw_devices++; | 573 | fs_info->fs_devices->rw_devices++; |
568 | 574 | ||
569 | /* replace the sysfs entry */ | ||
570 | btrfs_kobj_rm_device(fs_info, src_device); | ||
571 | btrfs_kobj_add_device(fs_info, tgt_device); | ||
572 | |||
573 | btrfs_dev_replace_unlock(dev_replace); | 575 | btrfs_dev_replace_unlock(dev_replace); |
574 | 576 | ||
575 | btrfs_rm_dev_replace_blocked(fs_info); | 577 | btrfs_rm_dev_replace_blocked(fs_info); |
576 | 578 | ||
577 | btrfs_rm_dev_replace_srcdev(fs_info, src_device); | 579 | btrfs_rm_dev_replace_remove_srcdev(fs_info, src_device); |
578 | 580 | ||
579 | btrfs_rm_dev_replace_unblocked(fs_info); | 581 | btrfs_rm_dev_replace_unblocked(fs_info); |
580 | 582 | ||
@@ -589,6 +591,11 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
589 | mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); | 591 | mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); |
590 | mutex_unlock(&uuid_mutex); | 592 | mutex_unlock(&uuid_mutex); |
591 | 593 | ||
594 | /* replace the sysfs entry */ | ||
595 | btrfs_kobj_rm_device(fs_info, src_device); | ||
596 | btrfs_kobj_add_device(fs_info, tgt_device); | ||
597 | btrfs_rm_dev_replace_free_srcdev(fs_info, src_device); | ||
598 | |||
592 | /* write back the superblocks */ | 599 | /* write back the superblocks */ |
593 | trans = btrfs_start_transaction(root, 0); | 600 | trans = btrfs_start_transaction(root, 0); |
594 | if (!IS_ERR(trans)) | 601 | if (!IS_ERR(trans)) |