When resync finished, report the mismatch count if there is one.

This doesn't get mailed out, but will appear in syslog...
Maybe it should be mailed if it was a 'check' or 'repair' pass...
This commit is contained in:
Neil Brown 2006-12-14 17:31:25 +11:00
parent b90c0e9a12
commit 37dfc3d638
4 changed files with 28 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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