]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Monitor.c
imsm: Remove --dump/--restore implementation
[thirdparty/mdadm.git] / Monitor.c
index 497e3642507be147536d7743c0b8d0f11e350156..b527165b803acc2eb3a9d84132f44a39f64aeba1 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -466,7 +466,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
        int new_array = 0;
        int retval;
        int is_container = 0;
-       unsigned long array_only_flags = 0;
+       unsigned long redundancy_only_flags = 0;
 
        if (test)
                alert("TestMessage", dev, NULL, ainfo);
@@ -504,11 +504,11 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
        if (md_get_array_info(fd, &array) < 0)
                goto disappeared;
 
-       if (!is_container)
-               array_only_flags |= GET_MISMATCH;
+       if (!is_container && map_name(pers, mse->level) > 0)
+               redundancy_only_flags |= GET_MISMATCH;
 
        sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEVS |
-                       GET_STATE | array_only_flags);
+                       GET_STATE | redundancy_only_flags);
 
        if (!sra)
                goto disappeared;
@@ -557,7 +557,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
                alert("RebuildStarted", dev, NULL, ainfo);
        if (st->percent >= 0 && mse->percent >= 0 &&
            (mse->percent / increments) > (st->percent / increments)) {
-               char percentalert[15];
+               char percentalert[18];
                /*
                 * "RebuildNN" (10 chars) or "RebuildStarted" (15 chars)
                 */
@@ -1055,10 +1055,13 @@ int Wait(char *dev)
        }
 }
 
+/* The state "broken" is used only for RAID0/LINEAR - it's the same as
+ * "clean", but used in case the array has one or more members missing.
+ */
 static char *clean_states[] = {
-       "clear", "inactive", "readonly", "read-auto", "clean", NULL };
+       "clear", "inactive", "readonly", "read-auto", "clean", "broken", NULL };
 
-int WaitClean(char *dev, int sock, int verbose)
+int WaitClean(char *dev, int verbose)
 {
        int fd;
        struct mdinfo *mdi;
@@ -1116,7 +1119,8 @@ int WaitClean(char *dev, int sock, int verbose)
                        rv = read(state_fd, buf, sizeof(buf));
                        if (rv < 0)
                                break;
-                       if (sysfs_match_word(buf, clean_states) <= 4)
+                       if (sysfs_match_word(buf, clean_states) <
+                           (int)ARRAY_SIZE(clean_states) - 1)
                                break;
                        rv = sysfs_wait(state_fd, &delay);
                        if (rv < 0 && errno != EINTR)
@@ -1125,15 +1129,16 @@ int WaitClean(char *dev, int sock, int verbose)
                }
                if (rv < 0)
                        rv = 1;
-               else if (fping_monitor(sock) == 0 ||
-                        ping_monitor(mdi->text_version) == 0) {
+               else if (ping_monitor(mdi->text_version) == 0) {
                        /* we need to ping to close the window between array
                         * state transitioning to clean and the metadata being
                         * marked clean
                         */
                        rv = 0;
-               } else
+               } else {
                        rv = 1;
+                       pr_err("Error connecting monitor with %s\n", dev);
+               }
                if (rv && verbose)
                        pr_err("Error waiting for %s to be clean\n", dev);