From f94c116f56cb821bfd619481d94fcd78ab8b53c0 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 22 Nov 2010 19:35:25 +1100 Subject: [PATCH] detail/wait: better handling of monitoring sync action. 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 --- Detail.c | 4 ++-- mdadm.h | 2 +- mdstat.c | 22 +++++++++++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Detail.c b/Detail.c index e0817aa..fdfffb7 100644 --- 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) { + static char *sync_action[] = {", recovering",", resyncing",", reshaping",", checking"}; 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<percent < 0) ? "" : - (e->resync) ? ", resyncing": ", recovering", + (!e || e->percent < 0) ? "" : sync_action[e->resync], larray_size ? "": ", Not Started"); } if (array.raid_disks) diff --git a/mdadm.h b/mdadm.h index 3e22910..577d858 100644 --- 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 */ - 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; diff --git a/mdstat.c b/mdstat.c index 47be2bb..bb030bf 100644 --- 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); - if (strncmp(w,"resync", 4)==0) + if (strncmp(w,"resync", 6)==0) ent->resync = 1; + else if (strncmp(w, "reshape", 7)==0) + ent->resync = 2; + else + ent->resync = 0; } 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' &&