btrfs: dev-replace: go back to suspended state if target device is missing
authorAnand Jain <>
Sun, 11 Nov 2018 14:22:17 +0000 (22:22 +0800)
committerDavid Sterba <>
Mon, 17 Dec 2018 13:51:34 +0000 (14:51 +0100)
At the time of forced unmount we place the running replace to
BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED state, so when the system comes
back and expect the target device is missing.

Then let the replace state continue to be in
BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED as there isn't any matching scrub
running as part of replace.

Fixes: e93c89c1aaaa ("Btrfs: add new sources for device replace code")
CC: # 4.4+
Signed-off-by: Anand Jain <>
Reviewed-by: David Sterba <>
Signed-off-by: David Sterba <>

index 32da6901dc88eb9fdb89dd146b965ca51cd6204d..11df8f778b637478701dbc02c31ed70f6f11505a 100644 (file)
@@ -890,6 +890,8 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
                           "cannot continue dev_replace, tgtdev is missing");
                           "you may cancel the operation after 'mount -o degraded'");
+               dev_replace->replace_state =
+                                       BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED;
                return 0;