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 <neilb@suse.de>
This commit is contained in:
NeilBrown 2010-11-22 19:35:25 +11:00
parent 8453e70430
commit f94c116f56
3 changed files with 22 additions and 6 deletions

View File

@ -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<<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)

View File

@ -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;

View File

@ -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' &&