diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-04 08:01:02 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-04 08:01:02 -0500 |
commit | c09c9dd2e9c732658c744a802101d5c34fedde22 (patch) | |
tree | 89f930ede811e66e7a70761aaca079d779fed38a /fs/btrfs/dev-replace.c | |
parent | 727ae8be30b428082d3519817f4fb98b712d457d (diff) | |
parent | 06bf403de344a8a0811ebd24992d2a08022c5225 (diff) |
Merge branches 'acpi-pci' and 'pm-pci'
* acpi-pci:
x86/PCI/ACPI: Fix regression caused by commit 4d6b4e69a245
* pm-pci:
PCI / PM: Tune down retryable runtime suspend error messages
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r-- | fs/btrfs/dev-replace.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index e54dd5905cee..1e668fb7dd4c 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -327,19 +327,6 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
327 | args->start.tgtdev_name[0] == '\0') | 327 | args->start.tgtdev_name[0] == '\0') |
328 | return -EINVAL; | 328 | return -EINVAL; |
329 | 329 | ||
330 | /* | ||
331 | * Here we commit the transaction to make sure commit_total_bytes | ||
332 | * of all the devices are updated. | ||
333 | */ | ||
334 | trans = btrfs_attach_transaction(root); | ||
335 | if (!IS_ERR(trans)) { | ||
336 | ret = btrfs_commit_transaction(trans, root); | ||
337 | if (ret) | ||
338 | return ret; | ||
339 | } else if (PTR_ERR(trans) != -ENOENT) { | ||
340 | return PTR_ERR(trans); | ||
341 | } | ||
342 | |||
343 | /* the disk copy procedure reuses the scrub code */ | 330 | /* the disk copy procedure reuses the scrub code */ |
344 | mutex_lock(&fs_info->volume_mutex); | 331 | mutex_lock(&fs_info->volume_mutex); |
345 | ret = btrfs_dev_replace_find_srcdev(root, args->start.srcdevid, | 332 | ret = btrfs_dev_replace_find_srcdev(root, args->start.srcdevid, |
@@ -356,6 +343,19 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
356 | if (ret) | 343 | if (ret) |
357 | return ret; | 344 | return ret; |
358 | 345 | ||
346 | /* | ||
347 | * Here we commit the transaction to make sure commit_total_bytes | ||
348 | * of all the devices are updated. | ||
349 | */ | ||
350 | trans = btrfs_attach_transaction(root); | ||
351 | if (!IS_ERR(trans)) { | ||
352 | ret = btrfs_commit_transaction(trans, root); | ||
353 | if (ret) | ||
354 | return ret; | ||
355 | } else if (PTR_ERR(trans) != -ENOENT) { | ||
356 | return PTR_ERR(trans); | ||
357 | } | ||
358 | |||
359 | btrfs_dev_replace_lock(dev_replace); | 359 | btrfs_dev_replace_lock(dev_replace); |
360 | switch (dev_replace->replace_state) { | 360 | switch (dev_replace->replace_state) { |
361 | case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED: | 361 | case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED: |
@@ -375,12 +375,8 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
375 | WARN_ON(!tgt_device); | 375 | WARN_ON(!tgt_device); |
376 | dev_replace->tgtdev = tgt_device; | 376 | dev_replace->tgtdev = tgt_device; |
377 | 377 | ||
378 | ret = btrfs_kobj_add_device(tgt_device->fs_devices, tgt_device); | 378 | btrfs_info_in_rcu(root->fs_info, |
379 | if (ret) | 379 | "dev_replace from %s (devid %llu) to %s started", |
380 | btrfs_err(root->fs_info, "kobj add dev failed %d\n", ret); | ||
381 | |||
382 | printk_in_rcu(KERN_INFO | ||
383 | "BTRFS: dev_replace from %s (devid %llu) to %s started\n", | ||
384 | src_device->missing ? "<missing disk>" : | 380 | src_device->missing ? "<missing disk>" : |
385 | rcu_str_deref(src_device->name), | 381 | rcu_str_deref(src_device->name), |
386 | src_device->devid, | 382 | src_device->devid, |
@@ -401,6 +397,10 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
401 | args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; | 397 | args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; |
402 | btrfs_dev_replace_unlock(dev_replace); | 398 | btrfs_dev_replace_unlock(dev_replace); |
403 | 399 | ||
400 | ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device); | ||
401 | if (ret) | ||
402 | btrfs_err(root->fs_info, "kobj add dev failed %d\n", ret); | ||
403 | |||
404 | btrfs_wait_ordered_roots(root->fs_info, -1); | 404 | btrfs_wait_ordered_roots(root->fs_info, -1); |
405 | 405 | ||
406 | /* force writing the updated state information to disk */ | 406 | /* force writing the updated state information to disk */ |
@@ -454,8 +454,7 @@ static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) | |||
454 | static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info) | 454 | static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info) |
455 | { | 455 | { |
456 | clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); | 456 | clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); |
457 | if (waitqueue_active(&fs_info->replace_wait)) | 457 | wake_up(&fs_info->replace_wait); |
458 | wake_up(&fs_info->replace_wait); | ||
459 | } | 458 | } |
460 | 459 | ||
461 | static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | 460 | static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, |
@@ -523,8 +522,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
523 | src_device, | 522 | src_device, |
524 | tgt_device); | 523 | tgt_device); |
525 | } else { | 524 | } else { |
526 | printk_in_rcu(KERN_ERR | 525 | btrfs_err_in_rcu(root->fs_info, |
527 | "BTRFS: btrfs_scrub_dev(%s, %llu, %s) failed %d\n", | 526 | "btrfs_scrub_dev(%s, %llu, %s) failed %d", |
528 | src_device->missing ? "<missing disk>" : | 527 | src_device->missing ? "<missing disk>" : |
529 | rcu_str_deref(src_device->name), | 528 | rcu_str_deref(src_device->name), |
530 | src_device->devid, | 529 | src_device->devid, |
@@ -540,8 +539,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
540 | return scrub_ret; | 539 | return scrub_ret; |
541 | } | 540 | } |
542 | 541 | ||
543 | printk_in_rcu(KERN_INFO | 542 | btrfs_info_in_rcu(root->fs_info, |
544 | "BTRFS: dev_replace from %s (devid %llu) to %s finished\n", | 543 | "dev_replace from %s (devid %llu) to %s finished", |
545 | src_device->missing ? "<missing disk>" : | 544 | src_device->missing ? "<missing disk>" : |
546 | rcu_str_deref(src_device->name), | 545 | rcu_str_deref(src_device->name), |
547 | src_device->devid, | 546 | src_device->devid, |
@@ -586,7 +585,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
586 | mutex_unlock(&uuid_mutex); | 585 | mutex_unlock(&uuid_mutex); |
587 | 586 | ||
588 | /* replace the sysfs entry */ | 587 | /* replace the sysfs entry */ |
589 | btrfs_kobj_rm_device(fs_info->fs_devices, src_device); | 588 | btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device); |
590 | btrfs_rm_dev_replace_free_srcdev(fs_info, src_device); | 589 | btrfs_rm_dev_replace_free_srcdev(fs_info, src_device); |
591 | 590 | ||
592 | /* write back the superblocks */ | 591 | /* write back the superblocks */ |
@@ -809,8 +808,8 @@ static int btrfs_dev_replace_kthread(void *data) | |||
809 | progress = status_args->status.progress_1000; | 808 | progress = status_args->status.progress_1000; |
810 | kfree(status_args); | 809 | kfree(status_args); |
811 | progress = div_u64(progress, 10); | 810 | progress = div_u64(progress, 10); |
812 | printk_in_rcu(KERN_INFO | 811 | btrfs_info_in_rcu(fs_info, |
813 | "BTRFS: continuing dev_replace from %s (devid %llu) to %s @%u%%\n", | 812 | "continuing dev_replace from %s (devid %llu) to %s @%u%%", |
814 | dev_replace->srcdev->missing ? "<missing disk>" : | 813 | dev_replace->srcdev->missing ? "<missing disk>" : |
815 | rcu_str_deref(dev_replace->srcdev->name), | 814 | rcu_str_deref(dev_replace->srcdev->name), |
816 | dev_replace->srcdev->devid, | 815 | dev_replace->srcdev->devid, |