]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Don't break long strings onto multiple lines.
[thirdparty/mdadm.git] / Assemble.c
index 63e09ac32b71921536941e178b4f3d86e631a461..131f871a6d1ec1843384cb57c85e0b07ed6ed545 100644 (file)
@@ -233,8 +233,7 @@ static int select_devices(struct mddev_dev *devlist,
                                   !conf_test_metadata(tst->ss->name, (pol = devid_policy(stb.st_rdev)),
                                                       tst->ss->match_home(tst, c->homehost) == 1)) {
                                if (report_mismatch)
-                                       pr_err("%s has metadata type %s for which "
-                                              "auto-assembly is disabled\n",
+                                       pr_err("%s has metadata type %s for which auto-assembly is disabled\n",
                                               devname, tst->ss->name);
                                tmpdev->used = 2;
                        } else
@@ -259,8 +258,7 @@ static int select_devices(struct mddev_dev *devlist,
                                   !conf_test_metadata(tst->ss->name, (pol = devid_policy(stb.st_rdev)),
                                                       tst->ss->match_home(tst, c->homehost) == 1)) {
                                if (report_mismatch)
-                                       pr_err("%s has metadata type %s for which "
-                                              "auto-assembly is disabled\n",
+                                       pr_err("%s has metadata type %s for which auto-assembly is disabled\n",
                                               devname, tst->ss->name);
                                tmpdev->used = 2;
                        }
@@ -350,8 +348,7 @@ static int select_devices(struct mddev_dev *devlist,
 
                        st = tst; tst = NULL;
                        if (!auto_assem && inargv && tmpdev->next != NULL) {
-                               pr_err("%s is a container, but is not "
-                                      "only device given: confused and aborting\n",
+                               pr_err("%s is a container, but is not only device given: confused and aborting\n",
                                       devname);
                                st->ss->free_super(st);
                                dev_policy_free(pol);
@@ -366,9 +363,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 +371,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
@@ -631,8 +633,7 @@ static int load_devices(struct devs *devices, char *devmap,
                                                            c->homehost);
                        if (err < 0) {
                                if (err == -1)
-                                       pr_err("--update=%s not understood"
-                                              " for %s metadata\n",
+                                       pr_err("--update=%s not understood for %s metadata\n",
                                               c->update, tst->ss->name);
                                tst->ss->free_super(tst);
                                free(tst);
@@ -757,12 +758,9 @@ static int load_devices(struct devs *devices, char *devmap,
                                 * Could be a mis-detection caused by overlapping
                                 * partitions.  fail-safe.
                                 */
-                               pr_err("WARNING %s and %s appear"
-                                      " to have very similar superblocks.\n"
-                                      "      If they are really different, "
-                                      "please --zero the superblock on one\n"
-                                      "      If they are the same or overlap,"
-                                      " please remove one from %s.\n",
+                               pr_err("WARNING %s and %s appear to have very similar superblocks.\n"
+                                      "      If they are really different, please --zero the superblock on one\n"
+                                      "      If they are the same or overlap, please remove one from %s.\n",
                                       devices[best[i]].devname, devname,
                                       inargv ? "the list" :
                                       "the\n      DEVICE list in mdadm.conf"
@@ -963,8 +961,7 @@ static int start_array(int mdfd,
                        rv = add_disk(mdfd, st, content, &devices[j].i);
 
                        if (rv) {
-                               pr_err("failed to add "
-                                      "%s to %s: %s\n",
+                               pr_err("failed to add %s to %s: %s\n",
                                       devices[j].devname,
                                       mddev,
                                       strerror(errno));
@@ -993,14 +990,29 @@ static int start_array(int mdfd,
 
        if (content->array.level == LEVEL_CONTAINER) {
                if (c->verbose >= 0) {
-                       pr_err("Container %s has been "
-                              "assembled with %d drive%s",
+                       pr_err("Container %s has been assembled with %d drive%s",
                               mddev, okcnt+sparecnt, okcnt+sparecnt==1?"":"s");
                        if (okcnt < (unsigned)content->array.raid_disks)
                                fprintf(stderr, " (out of %d)",
                                        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)
@@ -1120,15 +1132,12 @@ static int start_array(int mdfd,
 
                if (!enough(content->array.level, content->array.raid_disks,
                            content->array.layout, 1, avail))
-                       pr_err("Not enough devices to "
-                              "start the array.\n");
+                       pr_err("Not enough devices to start the array.\n");
                else if (!enough(content->array.level,
                                 content->array.raid_disks,
                                 content->array.layout, clean,
                                 avail))
-                       pr_err("Not enough devices to "
-                              "start the array while not clean "
-                              "- consider --force.\n");
+                       pr_err("Not enough devices to start the array while not clean - consider --force.\n");
 
                return 1;
        }
@@ -1153,9 +1162,7 @@ static int start_array(int mdfd,
                                 content->array.raid_disks,
                                 content->array.layout, clean,
                                 avail))
-                       fprintf(stderr, " - not enough to start the "
-                               "array while not clean - consider "
-                               "--force.\n");
+                       fprintf(stderr, " - not enough to start the array while not clean - consider --force.\n");
                else {
                        if (req_cnt == (unsigned)content->array.raid_disks)
                                fprintf(stderr, " - need all %d to start it", req_cnt);
@@ -1677,8 +1684,7 @@ try_again:
                int err = 0;
                int *fdlist = xmalloc(sizeof(int)* bestcnt);
                if (c->verbose > 0)
-                       pr_err(":%s has an active reshape - checking "
-                              "if critical section needs to be restored\n",
+                       pr_err(":%s has an active reshape - checking if critical section needs to be restored\n",
                               chosen_name);
                if (!c->backup_file)
                        c->backup_file = locate_backup(content->sys_name);
@@ -1706,8 +1712,7 @@ try_again:
                                                   c->backup_file, c->verbose > 0);
                        if (err && c->invalid_backup) {
                                if (c->verbose > 0)
-                                       pr_err("continuing"
-                                              " without restoring backup\n");
+                                       pr_err("continuing without restoring backup\n");
                                err = 0;
                        }
                }