summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-06-04 12:31:40 +1000
committerNeilBrown <neilb@suse.de>2012-09-27 16:49:54 +1000
commitfcf2195994b2ee8b0032e8493c64fc15cddfe9f7 (patch)
treefc9ee070d31160b7614b0cb109f4bce357fdab79
parent42f0ca1e1a455d186a9d5ae6822d42e8def64524 (diff)
downloadmdadm-fcf2195994b2ee8b0032e8493c64fc15cddfe9f7.tar.gz
Monitor: fix inconsistencies in values for ->percent
->percent sometimes stores negative values recording states like 'pending' or 'delayed'. The value '-2' means both 'delayed' and in Monitor, 'unknown'. Also, '-1' has a meaning but not #define. So change the #defines to be prefixed with "RESYNC_", instead of "PROCESS_", add new "_NONE" and "_UNKNOWN", and use correct value in each location. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Detail.c8
-rw-r--r--Monitor.c10
-rw-r--r--mdadm.h6
-rw-r--r--mdstat.c12
4 files changed, 19 insertions, 17 deletions
diff --git a/Detail.c b/Detail.c
index ae15846..85e2b89 100644
--- a/Detail.c
+++ b/Detail.c
@@ -374,11 +374,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre
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],
+ (!e || (e->percent < 0 && e->percent != RESYNC_PENDING &&
+ e->percent != RESYNC_DELAYED)) ? "" : sync_action[e->resync],
larray_size ? "": ", Not Started",
- e->percent == PROCESS_DELAYED ? " (DELAYED)": "",
- e->percent == PROCESS_PENDING ? " (PENDING)": "");
+ e->percent == RESYNC_DELAYED ? " (DELAYED)": "",
+ e->percent == RESYNC_PENDING ? " (PENDING)": "");
}
if (array.raid_disks)
printf(" Active Devices : %d\n", array.active_disks);
diff --git a/Monitor.c b/Monitor.c
index b0a242b..4fed1d3 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -183,7 +183,7 @@ int Monitor(struct mddev_dev *devlist,
}
st->next = statelist;
st->devnum = INT_MAX;
- st->percent = -2;
+ st->percent = RESYNC_UNKNOWN;
st->expected_spares = mdlist->spare_disks;
if (mdlist->spare_group)
st->spare_group = strdup(mdlist->spare_group);
@@ -199,7 +199,7 @@ int Monitor(struct mddev_dev *devlist,
st->devname = strdup(dv->devname);
st->next = statelist;
st->devnum = INT_MAX;
- st->percent = -2;
+ st->percent = RESYNC_UNKNOWN;
st->expected_spares = -1;
if (mdlist) {
st->expected_spares = mdlist->spare_disks;
@@ -541,7 +541,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->expected_spares > 0 &&
array.spare_disks < st->expected_spares)
alert("SparesMissing", dev, NULL, ainfo);
- if (st->percent == -1 &&
+ if (st->percent < 0 && st->percent != RESYNC_UNKNOWN &&
mse->percent >= 0)
alert("RebuildStarted", dev, NULL, ainfo);
if (st->percent >= 0 &&
@@ -557,7 +557,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
alert(percentalert, dev, NULL, ainfo);
}
- if (mse->percent == -1 &&
+ if (mse->percent == RESYNC_NONE &&
st->percent >= 0) {
/* Rebuild/sync/whatever just finished.
* If there is a number in /mismatch_cnt,
@@ -707,7 +707,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
st->next = *statelist;
st->err = 1;
st->devnum = mse->devnum;
- st->percent = -2;
+ st->percent = RESYNC_UNKNOWN;
st->expected_spares = -1;
if (mse->metadata_version &&
strncmp(mse->metadata_version, "external:", 9) == 0 &&
diff --git a/mdadm.h b/mdadm.h
index 4946d4e..4cf34ab 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1393,8 +1393,10 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
#define PATH_MAX 4096
#endif
-#define PROCESS_DELAYED -2
-#define PROCESS_PENDING -3
+#define RESYNC_NONE -1
+#define RESYNC_DELAYED -2
+#define RESYNC_PENDING -3
+#define RESYNC_UNKNOWN -4
/* When using "GET_DISK_INFO" it isn't certain how high
* we need to check. So we impose an absolute limit of
diff --git a/mdstat.c b/mdstat.c
index 6ead24c..1740560 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -185,7 +185,7 @@ struct mdstat_ent *mdstat_read(int hold, int start)
}
ent->dev = ent->level = ent->pattern= NULL;
ent->next = NULL;
- ent->percent = -1;
+ ent->percent = RESYNC_NONE;
ent->active = -1;
ent->resync = 0;
ent->metadata_version = NULL;
@@ -240,7 +240,7 @@ struct mdstat_ent *mdstat_read(int hold, int start)
ent->pattern = strdup(w+1);
if (ent->pattern[l-2]==']')
ent->pattern[l-2] = '\0';
- } else if (ent->percent == -1 &&
+ } else if (ent->percent == RESYNC_NONE &&
strncmp(w, "re", 2)== 0 &&
w[l-1] == '%' &&
(eq=strchr(w, '=')) != NULL ) {
@@ -251,7 +251,7 @@ struct mdstat_ent *mdstat_read(int hold, int start)
ent->resync = 2;
else
ent->resync = 0;
- } else if (ent->percent == -1 &&
+ } else if (ent->percent == RESYNC_NONE &&
(w[0] == 'r' || w[0] == 'c')) {
if (strncmp(w, "resync", 4)==0)
ent->resync = 1;
@@ -263,10 +263,10 @@ struct mdstat_ent *mdstat_read(int hold, int start)
ent->resync = 3;
if (l > 8 && strcmp(w+l-8, "=DELAYED") == 0)
- ent->percent = PROCESS_DELAYED;
+ ent->percent = RESYNC_DELAYED;
if (l > 8 && strcmp(w+l-8, "=PENDING") == 0)
- ent->percent = PROCESS_PENDING;
- } else if (ent->percent == -1 &&
+ ent->percent = RESYNC_PENDING;
+ } else if (ent->percent == RESYNC_NONE &&
w[0] >= '0' &&
w[0] <= '9' &&
w[l-1] == '%') {