Skip to content

Commit b47dda2

Browse files
asjkdave
authored andcommitted
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> [ update changelog ] Signed-off-by: David Sterba <[email protected]>
1 parent d189dd7 commit b47dda2

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

fs/btrfs/dev-replace.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -805,16 +805,23 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
805805
btrfs_dev_replace_write_unlock(dev_replace);
806806
break;
807807
case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
808-
result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
809808
tgt_device = dev_replace->tgtdev;
810809
src_device = dev_replace->srcdev;
811810
btrfs_dev_replace_write_unlock(dev_replace);
812-
btrfs_scrub_cancel(fs_info);
813-
/* btrfs_dev_replace_finishing() will handle the cleanup part */
814-
btrfs_info_in_rcu(fs_info,
815-
"dev_replace from %s (devid %llu) to %s canceled",
816-
btrfs_dev_name(src_device), src_device->devid,
817-
btrfs_dev_name(tgt_device));
811+
ret = btrfs_scrub_cancel(fs_info);
812+
if (ret < 0) {
813+
result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED;
814+
} else {
815+
result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
816+
/*
817+
* btrfs_dev_replace_finishing() will handle the
818+
* cleanup part
819+
*/
820+
btrfs_info_in_rcu(fs_info,
821+
"dev_replace from %s (devid %llu) to %s canceled",
822+
btrfs_dev_name(src_device), src_device->devid,
823+
btrfs_dev_name(tgt_device));
824+
}
818825
break;
819826
case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
820827
/*

0 commit comments

Comments
 (0)