summaryrefslogtreecommitdiffstats
path: root/Monitor.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-06-04 04:57:52 +0200
committerNeilBrown <neilb@suse.de>2012-06-04 04:57:52 +0200
commit721b662b5b33830090c220bbb04bf1904d4b7eed (patch)
treea6d36fe8fdfa986d6611051d818e7444ad29066e /Monitor.c
parentMonitor: Report NewArray when an array the disappeared, reappears. (diff)
downloadmdadm-721b662b5b33830090c220bbb04bf1904d4b7eed.tar.xz
mdadm-721b662b5b33830090c220bbb04bf1904d4b7eed.zip
Monitor: fix reporting for Fail vs FailSpare etc.
The tests here were specific to 0.90 metadata and didn't work properly for 1.x metadata, where a device's "number" doesn't change. By checking if this is a new array we can avoid some corner cases. Then we test mostly based on state and not based on 'number' at all. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/Monitor.c b/Monitor.c
index b8e028ba..34b99d67 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -455,6 +455,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int i;
int remaining_disks;
int last_disk;
+ int new_array = 0;
if (test)
alert("TestMessage", dev, NULL, ainfo);
@@ -517,6 +518,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
/* New array appeared where previously had and error */
st->err = 0;
st->percent = RESYNC_NONE;
+ new_array = 1;
alert("NewArray", st->devname, NULL, ainfo);
}
@@ -614,10 +616,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int change;
char *dv = NULL;
disc.number = i;
- if (i >= last_disk) {
- newstate = 0;
- disc.major = disc.minor = 0;
- } else if (info[i].major || info[i].minor) {
+ if (i < last_disk &&
+ (info[i].major || info[i].minor)) {
newstate = info[i].state;
dv = map_dev_preferred(
info[i].major, info[i].minor, 1,
@@ -625,37 +625,22 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
disc.state = newstate;
disc.major = info[i].major;
disc.minor = info[i].minor;
- } else if (mse && mse->pattern && i < (int)strlen(mse->pattern)) {
- switch(mse->pattern[i]) {
- case 'U': newstate = 6 /* ACTIVE/SYNC */; break;
- case '_': newstate = 8 /* REMOVED */; break;
- }
- disc.major = disc.minor = 0;
- }
+ } else
+ newstate = (1 << MD_DISK_REMOVED);
+
if (dv == NULL && st->devid[i])
dv = map_dev_preferred(
major(st->devid[i]),
minor(st->devid[i]), 1, prefer);
change = newstate ^ st->devstate[i];
- if (st->utime && change && !st->err) {
- if (i < array.raid_disks &&
- (((newstate&change)&(1<<MD_DISK_FAULTY)) ||
- ((st->devstate[i]&change)&(1<<MD_DISK_ACTIVE)) ||
- ((st->devstate[i]&change)&(1<<MD_DISK_SYNC)))
- )
+ if (st->utime && change && !st->err && !new_array) {
+ if ((st->devstate[i]&change)&(1<<MD_DISK_SYNC))
alert("Fail", dev, dv, ainfo);
- else if (i >= array.raid_disks &&
+ else if ((newstate & (1<<MD_DISK_FAULTY)) &&
(disc.major || disc.minor) &&
- st->devid[i] == makedev(disc.major, disc.minor) &&
- ((newstate&change)&(1<<MD_DISK_FAULTY))
- )
+ st->devid[i] == makedev(disc.major, disc.minor))
alert("FailSpare", dev, dv, ainfo);
- else if (i < array.raid_disks &&
- ! (newstate & (1<<MD_DISK_REMOVED)) &&
- (((st->devstate[i]&change)&(1<<MD_DISK_FAULTY)) ||
- ((newstate&change)&(1<<MD_DISK_ACTIVE)) ||
- ((newstate&change)&(1<<MD_DISK_SYNC)))
- )
+ else if ((newstate&change)&(1<<MD_DISK_SYNC))
alert("SpareActive", dev, dv, ainfo);
}
st->devstate[i] = newstate;