]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - managemon.c
mdmon: fix wrong array state when disk fails during mdmon startup
[thirdparty/mdadm.git] / managemon.c
index 4e8539877823106c656a96eb905f5a9e901f5bf9..200cf83e3436a9b9890097b052b4fc379fb7e334 100644 (file)
@@ -266,9 +266,7 @@ static void add_disk_to_container(struct supertype *st, struct mdinfo *sd)
 {
        int dfd;
        char nm[20];
-       struct supertype *st2;
        struct metadata_update *update = NULL;
-       struct mdinfo info;
        mdu_disk_info_t dk = {
                .number = -1,
                .major = sd->disk.major,
@@ -287,25 +285,6 @@ static void add_disk_to_container(struct supertype *st, struct mdinfo *sd)
        if (dfd < 0)
                return;
 
-       /* Check the metadata and see if it is already part of this
-        * array
-        */
-       st2 = dup_super(st);
-       if (st2->ss->load_super(st2, dfd, NULL) == 0) {
-               st2->ss->getinfo_super(st2, &info, NULL);
-               if (st->ss->compare_super(st, st2) == 0 &&
-                   info.disk.raid_disk >= 0) {
-                       /* Looks like a good member of array.
-                        * Just accept it.
-                        * mdadm will incorporate any parts into
-                        * active arrays.
-                        */
-                       st2->ss->free_super(st2);
-                       return;
-               }
-       }
-       st2->ss->free_super(st2);
-
        st->update_tail = &update;
        st->ss->add_to_super(st, &dk, dfd, NULL, INVALID_SECTORS);
        st->ss->write_init_super(st);
@@ -699,7 +678,7 @@ static void manage_new(struct mdstat_ent *mdstat,
        mdi = sysfs_read(-1, mdstat->devnm,
                         GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
                         GET_SAFEMODE|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
-                        GET_LAYOUT);
+                        GET_LAYOUT|GET_DEVS_ALL);
 
        if (!mdi)
                return;
@@ -748,9 +727,7 @@ static void manage_new(struct mdstat_ent *mdstat,
        dprintf("inst: %s action: %d state: %d\n", inst,
                new->action_fd, new->info.state_fd);
 
-       if (sigterm)
-               new->info.safe_mode_delay = 1;
-       else if (mdi->safe_mode_delay >= 50)
+       if (mdi->safe_mode_delay >= 50)
                /* Normal start, mdadm set this. */
                new->info.safe_mode_delay = mdi->safe_mode_delay;
        else
@@ -824,7 +801,7 @@ void manage(struct mdstat_ent *mdstat, struct supertype *container)
                                break;
                        }
                }
-               if (a == NULL || !a->container)
+               if ((a == NULL || !a->container) && !sigterm)
                        manage_new(mdstat, container, a);
        }
 }