dm raid: fix false -EBUSY when handling check/repair message
authorHeinz Mauelshagen <heinzm@redhat.com>
Tue, 18 Dec 2018 16:35:41 +0000 (17:35 +0100)
committerMike Snitzer <snitzer@redhat.com>
Tue, 18 Dec 2018 18:48:35 +0000 (13:48 -0500)
Sending a check/repair message infrequently leads to -EBUSY instead of
properly identifying an active resync.  This occurs because
raid_message() is testing recovery bits in a racy way.

Fix by calling decipher_sync_action() from raid_message() to properly
identify the idle state of the RAID device.

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-raid.c

index e1dd162..adcfe8a 100644 (file)
@@ -3690,8 +3690,7 @@ static int raid_message(struct dm_target *ti, unsigned int argc, char **argv,
                        set_bit(MD_RECOVERY_INTR, &mddev->recovery);
                        md_reap_sync_thread(mddev);
                }
-       } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
-                  test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
+       } else if (decipher_sync_action(mddev, mddev->recovery) != st_idle)
                return -EBUSY;
        else if (!strcasecmp(argv[0], "resync"))
                ; /* MD_RECOVERY_NEEDED set below */