]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Fix parallel make problem.
[thirdparty/mdadm.git] / Assemble.c
index 8977928534b6efb884b68824510caeac243eac17..cdcdb0f8658bf8b0350bc627fd50eb1a64c423ee 100644 (file)
@@ -366,9 +366,6 @@ static int select_devices(struct mddev_dev *devlist,
                        tmpdev = NULL;
                        goto loop;
                } else {
-                       int rv = 0;
-                       struct mddev_ident *match;
-
                        content = *contentp;
                        tst->ss->getinfo_super(tst, content, NULL);
 
@@ -377,25 +374,33 @@ static int select_devices(struct mddev_dev *devlist,
                                           report_mismatch ? devname : NULL))
                                goto loop;
 
-                       match = conf_match(tst, content, devname,
-                                          report_mismatch ? c->verbose : -1,
-                                          &rv);
-                       if (!match && rv == 2)
-                               goto loop;
-                       if (match && match->devname &&
-                           strcasecmp(match->devname, "<ignore>") == 0) {
-                               if (report_mismatch)
-                                       pr_err("%s is a member of an explicitly ignored array\n",
-                                              devname);
-                               goto loop;
-                       }
-                       if (match && !ident_matches(match, content, tst,
-                                                   c->homehost, c->update,
-                                                   report_mismatch ? devname : NULL))
-                               /* Array exists  in mdadm.conf but some
-                                * details don't match, so reject it
+                       if (auto_assem) {
+                               /* Never auto-assemble things that conflict
+                                * with mdadm.conf in some way
                                 */
-                               goto loop;
+                               struct mddev_ident *match;
+                               int rv = 0;
+
+                               match = conf_match(tst, content, devname,
+                                                  report_mismatch ? c->verbose : -1,
+                                                  &rv);
+                               if (!match && rv == 2)
+                                       goto loop;
+                               if (match && match->devname &&
+                                   strcasecmp(match->devname, "<ignore>") == 0) {
+                                       if (report_mismatch)
+                                               pr_err("%s is a member of an explicitly ignored array\n",
+                                                      devname);
+                                       goto loop;
+                               }
+                               if (match && !ident_matches(match, content, tst,
+                                                           c->homehost, c->update,
+                                                           report_mismatch ? devname : NULL))
+                                       /* Array exists  in mdadm.conf but some
+                                        * details don't match, so reject it
+                                        */
+                                       goto loop;
+                       }
 
                        /* should be safe to try an exclusive open now, we
                         * have rejected anything that some other mdadm might
@@ -1001,6 +1006,22 @@ static int start_array(int mdfd,
                                        content->array.raid_disks);
                        fprintf(stderr, "\n");
                }
+
+               if (st->ss->validate_container) {
+                       struct mdinfo *devices_list;
+                       struct mdinfo *info_devices = xmalloc(sizeof(struct mdinfo)*(okcnt+sparecnt));
+                       unsigned int count;
+                       devices_list = NULL;
+                       for (count = 0; count < okcnt+sparecnt; count++) {
+                               info_devices[count] = devices[count].i;
+                               info_devices[count].next = devices_list;
+                               devices_list = &info_devices[count];
+                       }
+                       if (st->ss->validate_container(devices_list))
+                               pr_err("Mismatch detected!\n");
+                       free(info_devices);
+               }
+
                st->ss->free_super(st);
                sysfs_uevent(content, "change");
                if (err_ok && okcnt < (unsigned)content->array.raid_disks)
@@ -1044,7 +1065,7 @@ static int start_array(int mdfd,
                                           "array_state", "readonly");
                        if (rv == 0)
                                rv = Grow_continue(mdfd, st, content,
-                                                  c->backup_file,
+                                                  c->backup_file, 0,
                                                   c->freeze_reshape);
                } else if (c->readonly &&
                           sysfs_attribute_available(
@@ -1793,7 +1814,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
                               struct mdinfo *content, struct context *c,
                               char *chosen_name, int *result)
 {
-       struct mdinfo *dev, *sra;
+       struct mdinfo *dev, *sra, *dev2;
        int working = 0, preexist = 0;
        int expansion = 0;
        struct map_ent *map = NULL;
@@ -1804,7 +1825,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
 
        sysfs_init(content, mdfd, NULL);
 
-       sra = sysfs_read(mdfd, NULL, GET_VERSION);
+       sra = sysfs_read(mdfd, NULL, GET_VERSION|GET_DEVS);
        if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) {
                if (content->array.major_version == -1 &&
                    content->array.minor_version == -2 &&
@@ -1831,8 +1852,22 @@ int assemble_container_content(struct supertype *st, int mdfd,
        if (st->ss->external && content->recovery_blocked && start_reshape)
                block_subarray(content);
 
-       if (sra)
-               sysfs_free(sra);
+       for (dev2 = sra->devs; dev2; dev2 = dev2->next) {
+               for (dev = content->devs; dev; dev = dev->next)
+                       if (dev2->disk.major == dev->disk.major &&
+                           dev2->disk.minor == dev->disk.minor)
+                               break;
+               if (dev)
+                       continue;
+               /* Don't want this one any more */
+               if (sysfs_set_str(sra, dev2, "slot", "none") < 0 &&
+                   errno == EBUSY) {
+                       pr_err("Cannot remove old device %s: not updating %s\n", dev2->sys_name, sra->sys_name);
+                       sysfs_free(sra);
+                       return 1;
+               }
+               sysfs_set_str(sra, dev2, "state", "remove");
+       }
        old_raid_disks = content->array.raid_disks - content->delta_disks;
        avail = xcalloc(content->array.raid_disks, 1);
        for (dev = content->devs; dev; dev = dev->next) {
@@ -1847,6 +1882,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
                } else if (errno == EEXIST)
                        preexist++;
        }
+       sysfs_free(sra);
        if (working + expansion == 0 && c->runstop <= 0) {
                free(avail);
                return 1;/* Nothing new, don't try to start */
@@ -1912,7 +1948,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
                }
 
                err = Grow_continue(mdfd, st, content, c->backup_file,
-                                   c->freeze_reshape);
+                                   0, c->freeze_reshape);
        } else switch(content->array.level) {
                case LEVEL_LINEAR:
                case LEVEL_MULTIPATH: