]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Monitor.c
tests: raid6 repair is now tested on every different layout.
[thirdparty/mdadm.git] / Monitor.c
index 50ff7ecba117cf545b0f3158b4ac3d751f714e72..f19c2e58a5209728fc1af5447ec3dc5bacc63468 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -426,9 +426,13 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
                else
                        priority = LOG_INFO;
 
-               if (disc)
+               if (disc && disc[0] != ' ')
                        syslog(priority,
                               "%s event detected on md device %s, component device %s", event, dev, disc);
+               else if (disc)
+                       syslog(priority,
+                              "%s event detected on md device %s: %s",
+                              event, dev, disc);
                else
                        syslog(priority,
                               "%s event detected on md device %s",
@@ -503,7 +507,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
         */
        if (array.level == 0 || array.level == -1) {
                if (!st->err && !st->from_config)
-                       alert("DeviceDisappeared", dev, "Wrong-Level", ainfo);
+                       alert("DeviceDisappeared", dev, " Wrong-Level", ainfo);
                st->err++;
                close(fd);
                return 0;
@@ -683,6 +687,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
 {
        struct mdstat_ent *mse;
        int new_found = 0;
+       char *name;
 
        for (mse=mdstat; mse; mse=mse->next)
                if (mse->devnm[0] &&
@@ -693,7 +698,14 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
                        struct state *st = xcalloc(1, sizeof *st);
                        mdu_array_info_t array;
                        int fd;
-                       st->devname = xstrdup(get_md_name(mse->devnm));
+
+                       name = get_md_name(mse->devnm);
+                       if (!name) {
+                               free(st);
+                               continue;
+                       }
+
+                       st->devname = xstrdup(name);
                        if ((fd = open(st->devname, O_RDONLY)) < 0 ||
                            ioctl(fd, GET_ARRAY_INFO, &array)< 0) {
                                /* no such array */
@@ -981,6 +993,7 @@ int Wait(char *dev)
        struct stat stb;
        char devnm[32];
        int rv = 1;
+       int frozen_remaining = 3;
 
        if (stat(dev, &stb) != 0) {
                pr_err("Cannot find %s: %s\n", dev,
@@ -997,7 +1010,7 @@ int Wait(char *dev)
                        if (strcmp(e->devnm, devnm) == 0)
                                break;
 
-               if (e->percent == RESYNC_NONE) {
+               if (e && e->percent == RESYNC_NONE) {
                        /* We could be in the brief pause before something
                         * starts. /proc/mdstat doesn't show that, but
                         * sync_action does.
@@ -1007,8 +1020,15 @@ int Wait(char *dev)
                        sysfs_init(&mdi, -1, devnm);
                        if (sysfs_get_str(&mdi, NULL, "sync_action",
                                          buf, 20) > 0 &&
-                           strcmp(buf,"idle\n") != 0)
+                           strcmp(buf,"idle\n") != 0) {
                                e->percent = RESYNC_UNKNOWN;
+                               if (strcmp(buf, "frozen\n") == 0) {
+                                       if (frozen_remaining == 0)
+                                               e->percent = RESYNC_NONE;
+                                       else
+                                               frozen_remaining -= 1;
+                               }
+                       }
                }
                if (!e || e->percent == RESYNC_NONE) {
                        if (e && e->metadata_version &&