btrfs: dev-replace: replace's scrub must not be running in suspended state
authorAnand Jain <anand.jain@oracle.com>
Sun, 11 Nov 2018 14:22:21 +0000 (22:22 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:35 +0000 (14:51 +0100)
When the replace state is in the suspended state, btrfs_scrub_cancel()
should fail with -ENOTCONN as there is no scrub running. As a safety
catch check if btrfs_scrub_cancel() returns -ENOTCONN and assert if it
doesn't.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/dev-replace.c

index c0878ff8185a803e69024d5c13498855e2d594fd..a84affa425d4b0fa1e17fa89ca2253f2534f4264 100644 (file)
@@ -840,7 +840,9 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
 
                btrfs_dev_replace_write_unlock(dev_replace);
 
-               btrfs_scrub_cancel(fs_info);
+               /* Scrub for replace must not be running in suspended state */
+               ret = btrfs_scrub_cancel(fs_info);
+               ASSERT(ret != -ENOTCONN);
 
                trans = btrfs_start_transaction(root, 0);
                if (IS_ERR(trans)) {