]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
detail/wait: better handling of monitoring sync action.
authorNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)
Detail: report reshape and check as well as resync and recovery
Wait: if the resync is pending or delayed, wait for that too.

Signed-off-by: NeilBrown <neilb@suse.de>
Detail.c
mdadm.h
mdstat.c

index e0817aac20298c442ea32f59b33ad7298d92171e..fdfffb72ec0290e5ed5ada2380fc9310a7990f8c 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -355,6 +355,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                if (atime)
                        printf("    Update Time : %.24s\n", ctime(&atime));
                if (array.raid_disks) {
                if (atime)
                        printf("    Update Time : %.24s\n", ctime(&atime));
                if (array.raid_disks) {
+                       static char *sync_action[] = {", recovering",", resyncing",", reshaping",", checking"};
                        char *st;
                        if (avail_disks == array.raid_disks)
                                st = "";
                        char *st;
                        if (avail_disks == array.raid_disks)
                                st = "";
@@ -367,8 +368,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        printf("          State : %s%s%s%s\n",
                               (array.state&(1<<MD_SB_CLEAN))?"clean":"active",
                               st,
                        printf("          State : %s%s%s%s\n",
                               (array.state&(1<<MD_SB_CLEAN))?"clean":"active",
                               st,
-                              (!e || e->percent < 0) ? "" :
-                              (e->resync) ? ", resyncing": ", recovering",
+                              (!e || e->percent < 0) ? "" : sync_action[e->resync],
                               larray_size ? "": ", Not Started");
                }
                if (array.raid_disks)
                               larray_size ? "": ", Not Started");
                }
                if (array.raid_disks)
diff --git a/mdadm.h b/mdadm.h
index 3e229103d9a7166de7592cfbd967b8045506e591..577d858e49f54a27c421bf4acdab147df52ab95b 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -355,7 +355,7 @@ struct mdstat_ent {
        char            *level;
        char            *pattern; /* U or up, _ for down */
        int             percent; /* -1 if no resync */
        char            *level;
        char            *pattern; /* U or up, _ for down */
        int             percent; /* -1 if no resync */
-       int             resync; /* 1 if resync, 0 if recovery */
+       int             resync; /* 3 if check, 2 if reshape, 1 if resync, 0 if recovery */
        int             devcnt;
        int             raid_disks;
        int             chunk_size;
        int             devcnt;
        int             raid_disks;
        int             chunk_size;
index 47be2bba21fabaac7a617f8b4f0264f7fcd966a3..bb030bf391774fe491a9c8e70c3b6156a7c59c33 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -241,11 +241,27 @@ struct mdstat_ent *mdstat_read(int hold, int start)
                                   w[l-1] == '%' &&
                                   (eq=strchr(w, '=')) != NULL ) {
                                ent->percent = atoi(eq+1);
                                   w[l-1] == '%' &&
                                   (eq=strchr(w, '=')) != NULL ) {
                                ent->percent = atoi(eq+1);
-                               if (strncmp(w,"resync", 4)==0)
+                               if (strncmp(w,"resync", 6)==0)
                                        ent->resync = 1;
                                        ent->resync = 1;
+                               else if (strncmp(w, "reshape", 7)==0)
+                                       ent->resync = 2;
+                               else
+                                       ent->resync = 0;
                        } else if (ent->percent == -1 &&
                        } else if (ent->percent == -1 &&
-                                  strncmp(w, "resync", 4)==0) {
-                               ent->resync = 1;
+                                  (w[0] == 'r' || w[0] == 'c')) {
+                               if (strncmp(w, "resync", 4)==0)
+                                       ent->resync = 1;
+                               if (strncmp(w, "reshape", 7)==0)
+                                       ent->resync = 2;
+                               if (strncmp(w, "recovery", 8)==0)
+                                       ent->resync = 2;
+                               if (strncmp(w, "check", 5)==0)
+                                       ent->resync = 3;
+
+                               if (l > 8 && strcmp(w+l-8, "=DELAYED"))
+                                       ent->percent = 0;
+                               if (l > 8 && strcmp(w+l-8, "=PENDING"))
+                                       ent->percent = 0;
                        } else if (ent->percent == -1 &&
                                   w[0] >= '0' &&
                                   w[0] <= '9' &&
                        } else if (ent->percent == -1 &&
                                   w[0] >= '0' &&
                                   w[0] <= '9' &&