]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Wait: also wait if an action is about to start.
authorNeilBrown <neilb@suse.de>
Wed, 1 May 2013 00:23:40 +0000 (10:23 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 1 May 2013 00:23:40 +0000 (10:23 +1000)
If a sync/recover action is about to start but hasn't actually begun
yet, /proc/mdstat won't show it, but md/sync_action will (it checks
MD_RECOVERY_NEEDED).
So when /proc/mdstat seems to say nothing is happening, double check
with md/sync_action.

Signed-off-by: NeilBrown <neilb@suse.de>
Monitor.c

index 607d3ddd73243378ad137121e6d5355ef30f4b62..b82e7b6a5ba0c228e3eabd653264227036eca83c 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -972,6 +972,19 @@ int Wait(char *dev)
                        if (strcmp(e->devnm, devnm) == 0)
                                break;
 
+               if (e->percent == RESYNC_NONE) {
+                       /* We could be in the brief pause before something
+                        * starts. /proc/mdstat doesn't show that, but
+                        * sync_action does.
+                        */
+                       struct mdinfo mdi;
+                       char buf[21];
+                       sysfs_init(&mdi, -1, devnm);
+                       if (sysfs_get_str(&mdi, NULL, "sync_action",
+                                         buf, 20) > 0 &&
+                           strcmp(buf,"idle\n") != 0)
+                               e->percent = RESYNC_UNKNOWN;
+               }
                if (!e || e->percent == RESYNC_NONE) {
                        if (e && e->metadata_version &&
                            strncmp(e->metadata_version, "external:", 9) == 0) {