]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Show DELAYED, PENDING status of resync process in "--detail"
authorKrzysztof Wojcik <krzysztof.wojcik@intel.com>
Thu, 23 Jun 2011 02:06:47 +0000 (12:06 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 23 Jun 2011 02:06:47 +0000 (12:06 +1000)
Initially there is no proper translation mdstat's DELAYED/PENDING processes
to "--detail" output.
For example, if we have recover=DELAYED in mdstat, "--detail"
shows "State: recovering" and "Rebuild Status = 0%".
It was incorrect in case of process waiting on checkpoint different
than 0%. In fact rebuild status is differnt than 0% and user is misled.

The patch fix the problem. Current "--detail" command shows
in the exampe: "State: recovering (DELAYED)" and no information
about precentage.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Detail.c
mdadm.h
mdstat.c

index 40806cf0f973a4094f9e14d385063d7b3cd5fd75..ca34abeac28d5670a57e571ed82914e6751b73a8 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -372,11 +372,13 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        else
                                st = ", degraded";
 
-                       printf("          State : %s%s%s%s\n",
-                              (array.state&(1<<MD_SB_CLEAN))?"clean":"active",
-                              st,
-                              (!e || e->percent < 0) ? "" : sync_action[e->resync],
-                              larray_size ? "": ", Not Started");
+                       printf("          State : %s%s%s%s%s%s \n",
+                              (array.state&(1<<MD_SB_CLEAN))?"clean":"active", st,
+                              (!e || (e->percent < 0 && e->percent != PROCESS_PENDING &&
+                              e->percent != PROCESS_DELAYED)) ? "" : sync_action[e->resync],
+                              larray_size ? "": ", Not Started",
+                              e->percent == PROCESS_DELAYED ? " (DELAYED)": "",
+                              e->percent == PROCESS_PENDING ? " (PENDING)": "");
                }
                if (array.raid_disks)
                        printf(" Active Devices : %d\n", array.active_disks);
@@ -416,10 +418,8 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                }
 
                if (e && e->percent >= 0) {
-                       printf(" Re%s Status : %d%% complete\n",
-                              (st && st->sb && info->reshape_active)?
-                                 "shape":"build",
-                              e->percent);
+                       static char *sync_action[] = {"Rebuild", "Resync", "Reshape", "Check"};
+                       printf(" %7s Status : %d%% complete\n", sync_action[e->resync], e->percent);
                        is_rebuilding = 1;
                }
                free_mdstat(ms);
diff --git a/mdadm.h b/mdadm.h
index e075dd2aa74f7621600c4c030ee94e124dbc633f..8bd007733c9ad10010846dafc45d01344c3a4f37 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1345,3 +1345,5 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 #define PATH_MAX       4096
 #endif
 
+#define PROCESS_DELAYED -2
+#define PROCESS_PENDING -3
index 3d2edadb494dcad1a7db3528e493e60414741d8a..abf6bf953c309013bd3750bf9a58763d48fbe051 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -257,10 +257,10 @@ struct mdstat_ent *mdstat_read(int hold, int start)
                                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;
+                               if (l > 8 && strcmp(w+l-8, "=DELAYED") == 0)
+                                       ent->percent = PROCESS_DELAYED;
+                               if (l > 8 && strcmp(w+l-8, "=PENDING") == 0)
+                                       ent->percent = PROCESS_PENDING;
                        } else if (ent->percent == -1 &&
                                   w[0] >= '0' &&
                                   w[0] <= '9' &&