]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - managemon.c
mdadm: add missing --syslog option to monitor help
[thirdparty/mdadm.git] / managemon.c
index d6c57f78bd28a038d92dcad390272a79fbd82429..6662f675cc938e91a321734da3849d33d689c7c2 100644 (file)
@@ -436,6 +436,11 @@ static void manage_member(struct mdstat_ent *mdstat,
         */
        char buf[64];
        int frozen;
+       struct supertype *container = a->container;
+
+       if (container == NULL)
+               /* Raced with something */
+               return;
 
        // FIXME
        a->info.array.raid_disks = mdstat->raid_disks;
@@ -455,11 +460,16 @@ static void manage_member(struct mdstat_ent *mdstat,
 
        if (mdstat->level) {
                int level = map_name(pers, mdstat->level);
-               if (a->info.array.level != level && level >= 0) {
+               if (level == 0 || level == LEVEL_LINEAR) {
+                       a->container = NULL;
+                       wakeup_monitor();
+                       return;
+               }
+               else if (a->info.array.level != level && level > 0) {
                        struct active_array *newa = duplicate_aa(a);
                        if (newa) {
                                newa->info.array.level = level;
-                               replace_array(a->container, a, newa);
+                               replace_array(container, a, newa);
                                a = newa;
                        }
                }
@@ -481,7 +491,7 @@ static void manage_member(struct mdstat_ent *mdstat,
                /* The array may not be degraded, this is just a good time
                 * to check.
                 */
-               newdev = a->container->ss->activate_spare(a, &updates);
+               newdev = container->ss->activate_spare(a, &updates);
                if (!newdev)
                        return;
 
@@ -506,7 +516,7 @@ static void manage_member(struct mdstat_ent *mdstat,
                }
                queue_metadata_update(updates);
                updates = NULL;
-               replace_array(a->container, a, newa);
+               replace_array(container, a, newa);
                sysfs_set_str(&a->info, NULL, "sync_action", "recover");
  out:
                while (newdev) {
@@ -560,7 +570,7 @@ static void manage_member(struct mdstat_ent *mdstat,
        out2:
                sysfs_free(info);
                if (newa)
-                       replace_array(a->container, a, newa);
+                       replace_array(container, a, newa);
        }
 }
 
@@ -603,7 +613,10 @@ static void manage_new(struct mdstat_ent *mdstat,
        char buf[40];
 
        /* check if array is ready to be monitored */
-       if (!mdstat->active)
+       if (!mdstat->active || !mdstat->level)
+               return;
+       if (strcmp(mdstat->level, "raid0") == 0 ||
+           strcmp(mdstat->level, "linear") == 0)
                return;
 
        mdi = sysfs_read(-1, mdstat->devnum,