btrfs: dev-replace: set result code of cancel by status of scrub

The device-replace needs to check the result code of the scrub workers
in btrfs_dev_replace_cancel and distinguish if successful cancel
operation and when the there was no operation running.

If btrfs_scrub_cancel() fails, return
BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED so that user can try
to cancel the replace again.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain 2018-11-11 22:22:20 +08:00 committed by David Sterba
parent d189dd70e2
commit b47dda2ef6
1 changed files with 14 additions and 7 deletions

View File

@ -805,16 +805,23 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
btrfs_dev_replace_write_unlock(dev_replace); btrfs_dev_replace_write_unlock(dev_replace);
break; break;
case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED: case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
tgt_device = dev_replace->tgtdev; tgt_device = dev_replace->tgtdev;
src_device = dev_replace->srcdev; src_device = dev_replace->srcdev;
btrfs_dev_replace_write_unlock(dev_replace); btrfs_dev_replace_write_unlock(dev_replace);
btrfs_scrub_cancel(fs_info); ret = btrfs_scrub_cancel(fs_info);
/* btrfs_dev_replace_finishing() will handle the cleanup part */ if (ret < 0) {
btrfs_info_in_rcu(fs_info, result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED;
"dev_replace from %s (devid %llu) to %s canceled", } else {
btrfs_dev_name(src_device), src_device->devid, result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
btrfs_dev_name(tgt_device)); /*
* btrfs_dev_replace_finishing() will handle the
* cleanup part
*/
btrfs_info_in_rcu(fs_info,
"dev_replace from %s (devid %llu) to %s canceled",
btrfs_dev_name(src_device), src_device->devid,
btrfs_dev_name(tgt_device));
}
break; break;
case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED: case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
/* /*