aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 1be03d85d267..da7ac1432b15 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -418,7 +418,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
418 418
419 /* the disk copy procedure reuses the scrub code */ 419 /* the disk copy procedure reuses the scrub code */
420 ret = btrfs_scrub_dev(fs_info, src_device->devid, 0, 420 ret = btrfs_scrub_dev(fs_info, src_device->devid, 0,
421 src_device->total_bytes, 421 btrfs_device_get_total_bytes(src_device),
422 &dev_replace->scrub_progress, 0, 1); 422 &dev_replace->scrub_progress, 0, 1);
423 423
424 ret = btrfs_dev_replace_finishing(root->fs_info, ret); 424 ret = btrfs_dev_replace_finishing(root->fs_info, ret);
@@ -555,11 +555,12 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
555 memcpy(uuid_tmp, tgt_device->uuid, sizeof(uuid_tmp)); 555 memcpy(uuid_tmp, tgt_device->uuid, sizeof(uuid_tmp));
556 memcpy(tgt_device->uuid, src_device->uuid, sizeof(tgt_device->uuid)); 556 memcpy(tgt_device->uuid, src_device->uuid, sizeof(tgt_device->uuid));
557 memcpy(src_device->uuid, uuid_tmp, sizeof(src_device->uuid)); 557 memcpy(src_device->uuid, uuid_tmp, sizeof(src_device->uuid));
558 tgt_device->total_bytes = src_device->total_bytes; 558 btrfs_device_set_total_bytes(tgt_device, src_device->total_bytes);
559 tgt_device->disk_total_bytes = src_device->disk_total_bytes; 559 btrfs_device_set_disk_total_bytes(tgt_device,
560 src_device->disk_total_bytes);
561 btrfs_device_set_bytes_used(tgt_device, src_device->bytes_used);
560 ASSERT(list_empty(&src_device->resized_list)); 562 ASSERT(list_empty(&src_device->resized_list));
561 tgt_device->commit_total_bytes = src_device->commit_total_bytes; 563 tgt_device->commit_total_bytes = src_device->commit_total_bytes;
562 tgt_device->bytes_used = src_device->bytes_used;
563 tgt_device->commit_bytes_used = src_device->bytes_used; 564 tgt_device->commit_bytes_used = src_device->bytes_used;
564 if (fs_info->sb->s_bdev == src_device->bdev) 565 if (fs_info->sb->s_bdev == src_device->bdev)
565 fs_info->sb->s_bdev = tgt_device->bdev; 566 fs_info->sb->s_bdev = tgt_device->bdev;
@@ -650,6 +651,7 @@ void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
650 struct btrfs_ioctl_dev_replace_args *args) 651 struct btrfs_ioctl_dev_replace_args *args)
651{ 652{
652 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; 653 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
654 struct btrfs_device *srcdev;
653 655
654 btrfs_dev_replace_lock(dev_replace); 656 btrfs_dev_replace_lock(dev_replace);
655 /* even if !dev_replace_is_valid, the values are good enough for 657 /* even if !dev_replace_is_valid, the values are good enough for
@@ -672,8 +674,9 @@ void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
672 break; 674 break;
673 case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED: 675 case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
674 case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED: 676 case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
677 srcdev = dev_replace->srcdev;
675 args->status.progress_1000 = div64_u64(dev_replace->cursor_left, 678 args->status.progress_1000 = div64_u64(dev_replace->cursor_left,
676 div64_u64(dev_replace->srcdev->total_bytes, 1000)); 679 div64_u64(btrfs_device_get_total_bytes(srcdev), 1000));
677 break; 680 break;
678 } 681 }
679 btrfs_dev_replace_unlock(dev_replace); 682 btrfs_dev_replace_unlock(dev_replace);
@@ -832,7 +835,7 @@ static int btrfs_dev_replace_continue_on_mount(struct btrfs_fs_info *fs_info)
832 835
833 ret = btrfs_scrub_dev(fs_info, dev_replace->srcdev->devid, 836 ret = btrfs_scrub_dev(fs_info, dev_replace->srcdev->devid,
834 dev_replace->committed_cursor_left, 837 dev_replace->committed_cursor_left,
835 dev_replace->srcdev->total_bytes, 838 btrfs_device_get_total_bytes(dev_replace->srcdev),
836 &dev_replace->scrub_progress, 0, 1); 839 &dev_replace->scrub_progress, 0, 1);
837 ret = btrfs_dev_replace_finishing(fs_info, ret); 840 ret = btrfs_dev_replace_finishing(fs_info, ret);
838 WARN_ON(ret); 841 WARN_ON(ret);