summaryrefslogtreecommitdiffstats
path: root/Monitor.c
diff options
context:
space:
mode:
authorAnna Czarnowska <anna.czarnowska@intel.com>2010-11-22 10:58:06 +0100
committerNeilBrown <neilb@suse.de>2010-11-22 10:58:06 +0100
commit0eac199a2ce5d7febc071616450c26882779ed09 (patch)
tree993b1834d34f02b4541ed56e25f1f104380a6fb5 /Monitor.c
parentUtil: get device size from id (diff)
downloadmdadm-0eac199a2ce5d7febc071616450c26882779ed09.tar.xz
mdadm-0eac199a2ce5d7febc071616450c26882779ed09.zip
Monitor: set err on arrays not in mdstat
mse can be NULL when the array was not in mdstat when we read it but existed in statelist and was recreated after reading mdstat. In this case we set err as we can't get full update on this array this time. If the same array is given twice in command line it appears twice in statelist. The first one will mark mse->devnum=INT_MAX so the second one can't find mse. We set err on the second one as it's not needed. Also if it becomes degraded we would look for spares twice for the same array. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to '')
-rw-r--r--Monitor.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/Monitor.c b/Monitor.c
index fa275126..c4256815 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -271,6 +271,14 @@ int Monitor(struct mddev_dev *devlist,
mse = mse2;
}
+ if (!mse) {
+ /* duplicated array in statelist
+ * or re-created after reading mdstat*/
+ st->err = 1;
+ close(fd);
+ continue;
+ }
+ /* this array is in /proc/mdstat */
if (array.utime == 0)
/* external arrays don't update utime */
array.utime = time(0);
@@ -287,7 +295,6 @@ int Monitor(struct mddev_dev *devlist,
continue;
}
if (st->utime == 0 && /* new array */
- mse && /* is in /proc/mdstat */
mse->pattern && strchr(mse->pattern, '_') /* degraded */
)
alert("DegradedArray", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
@@ -296,12 +303,10 @@ int Monitor(struct mddev_dev *devlist,
st->expected_spares > 0 &&
array.spare_disks < st->expected_spares)
alert("SparesMissing", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
- if (mse &&
- st->percent == -1 &&
+ if (st->percent == -1 &&
mse->percent >= 0)
alert("RebuildStarted", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
- if (mse &&
- st->percent >= 0 &&
+ if (st->percent >= 0 &&
mse->percent >= 0 &&
(mse->percent / increments) > (st->percent / increments)) {
char percentalert[15]; // "RebuildNN" (10 chars) or "RebuildStarted" (15 chars)
@@ -315,8 +320,7 @@ int Monitor(struct mddev_dev *devlist,
dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
}
- if (mse &&
- mse->percent == -1 &&
+ if (mse->percent == -1 &&
st->percent >= 0) {
/* Rebuild/sync/whatever just finished.
* If there is a number in /mismatch_cnt,
@@ -333,10 +337,7 @@ int Monitor(struct mddev_dev *devlist,
if (sra)
free(sra);
}
-
- if (mse)
- st->percent = mse->percent;
-
+ st->percent = mse->percent;
for (i=0; i<MaxDisks && i <= array.raid_disks + array.nr_disks;
i++) {