]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Factor out add-disk code
[thirdparty/mdadm.git] / Assemble.c
index cb2725db5ebe6db9a48606a0b67bd852cc295690..1f41369a8512acb5bf1d18748337d184f1ba343b 100644 (file)
@@ -542,8 +542,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                            == devices[devcnt].i.events
                            && (devices[best[i]].i.disk.minor
                                != devices[devcnt].i.disk.minor)
-                           && st->ss->major == 0
-                           && info.array.level != -4) {
+                           && st->ss == &super0
+                           && info.array.level != LEVEL_MULTIPATH) {
                                /* two different devices with identical superblock.
                                 * Could be a mis-detection caused by overlapping
                                 * partitions.  fail-safe.
@@ -844,10 +844,10 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
 
        /* Almost ready to actually *do* something */
        if (!old_linux) {
+               struct mdinfo *sra = NULL;
                int rv;
 
 #ifndef MDASSEMBLE
-               struct mdinfo *sra;
                if (st->ss->external) {
                        char ver[100];
                        strcat(strcpy(ver, "external:"), info.text_version);
@@ -866,8 +866,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                if ((vers % 100) >= 1) { /* can use different versions */
                        mdu_array_info_t inf;
                        memset(&inf, 0, sizeof(inf));
-                       inf.major_version = st->ss->major;
-                       inf.minor_version = st->minor_version;
+                       inf.major_version = info.array.major_version;
+                       inf.minor_version = info.array.minor_version;
                        rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
                } else
                        rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
@@ -913,18 +913,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                                j = chosen_drive;
 
                        if (j >= 0 /* && devices[j].uptodate */) {
-#ifndef MDASSEMBLE
-                               if (st->ss->external) {
-                                       devices[j].i.disk.number =
-                                               devices[j].i.disk.raid_disk;
-                                       st->ss->getinfo_super_n(st,
-                                                               &devices[j].i);
-                                       rv = sysfs_add_disk(sra,
-                                                           &devices[j].i);
-                               } else
-#endif
-                                       rv = ioctl(mdfd, ADD_NEW_DISK,
-                                         &devices[j].i.disk);
+                               rv = add_disk(mdfd, st, sra, &devices[j].i);
+
                                if (rv) {
                                        fprintf(stderr, Name ": failed to add "
                                                        "%s to %s: %s\n",