]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
When resync finished, report the mismatch count if there is one.
authorNeil Brown <neilb@suse.de>
Thu, 14 Dec 2006 06:31:25 +0000 (17:31 +1100)
committerNeil Brown <neilb@suse.de>
Thu, 14 Dec 2006 06:31:25 +0000 (17:31 +1100)
This doesn't get mailed out, but will appear in syslog...
Maybe it should be mailed if it was a 'check' or 'repair' pass...

Monitor.c
mdadm.h
super1.c
sysfs.c

index 5091c51b3c7d091bd044fa35c7b555288e6d3f65..f7bb48ce96986ae187f94ed0e667a775d23b0f94 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -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");
 
diff --git a/mdadm.h b/mdadm.h
index f1768a53c621de1c8f4662b788021b5056093278..f6350e1870fb34c339da7acfcc37a1c8c82269d2 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -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
index b7d1c996e88a824bdd3eb492aef2897b7a891bac..be1a0e5baf9d4be2494b0f4086e5e2d478ea4aff 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -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);
 
diff --git a/sysfs.c b/sysfs.c
index 166481f1a54580f652d191a932251dfbfa4190bd..25ede6b7b054fe6754353400ae4590bc34fb1cbe 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -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;