diff options
-rw-r--r-- | Monitor.c | 22 | ||||
-rw-r--r-- | mdadm.h | 2 | ||||
-rw-r--r-- | super1.c | 2 | ||||
-rw-r--r-- | sysfs.c | 6 |
4 files changed, 28 insertions, 4 deletions
@@ -303,8 +303,22 @@ int Monitor(mddev_dev_t devlist, if (mse && mse->percent == -1 && - st->percent >= 0) - alert("RebuildFinished", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog); + st->percent >= 0) { + /* Rebuild/sync/whatever just finished. + * If there is a number in /mismatch_cnt, + * we should report that. + */ + struct sysarray *sra = + sysfs_read(-1, st->devnum, GET_MISMATCH); + if (sra && sra->mismatch_cnt > 0) { + char cnt[40]; + sprintf(cnt, " mismatches found: %d", sra->mismatch_cnt); + alert("RebuildFinished", dev, cnt, mailaddr, mailfrom, alert_cmd, dosyslog); + } else + alert("RebuildFinished", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog); + if (sra) + free(sra); + } if (mse) st->percent = mse->percent; @@ -510,8 +524,10 @@ static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mail fprintf(mp, "A %s event had been detected on md device %s.\n\n", event, dev); - if (disc) + if (disc && disc[0] != ' ') fprintf(mp, "It could be related to component device %s.\n\n", disc); + if (disc && disc[0] == ' ') + fprintf(mp, "Extra information:%s.\n\n", disc); fprintf(mp, "Faithfully yours, etc.\n"); @@ -258,6 +258,7 @@ struct sysarray { int level; int spares; int cache_size; + int mismatch_cnt; }; /* various details can be requested */ #define GET_LEVEL 1 @@ -265,6 +266,7 @@ struct sysarray { #define GET_COMPONENT 4 #define GET_CHUNK 8 #define GET_CACHE 16 +#define GET_MISMATCH 32 #define GET_DEVS 1024 /* gets role, major, minor */ #define GET_OFFSET 2048 @@ -1164,7 +1164,7 @@ add_internal_bitmap1(struct supertype *st, void *sbv, unsigned long long min_chunk; long offset; int chunk = *chunkp; - int room; + int room = 0; struct mdp_superblock_1 *sb = sbv; bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + 1024); @@ -113,6 +113,12 @@ struct sysarray *sysfs_read(int fd, int devnum, unsigned long options) goto abort; sra->cache_size = strtoul(buf, NULL, 0); } + if (options & GET_MISMATCH) { + strcpy(base, "mismatch_cnt"); + if (load_sys(fname, buf)) + goto abort; + sra->mismatch_cnt = strtoul(buf, NULL, 0); + } if (! (options & GET_DEVS)) return sra; |