]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Retire mdassemble
[thirdparty/mdadm.git] / Assemble.c
index c09842016c0afcbca48c2262da5f09b2f347e80c..b8285239354b60b78cebc0919470cc536122f2a9 100644 (file)
@@ -222,13 +222,11 @@ static int select_devices(struct mddev_dev *devlist,
                                        pr_err("%s is a container, but we are looking for components\n",
                                               devname);
                                tmpdev->used = 2;
-#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
                        } if (!tst && (tst = super_by_fd(dfd, NULL)) == NULL) {
                                if (report_mismatch)
                                        pr_err("not a recognisable container: %s\n",
                                               devname);
                                tmpdev->used = 2;
-#endif
                        } else if (!tst->ss->load_container
                                   || tst->ss->load_container(tst, dfd, NULL)) {
                                if (report_mismatch)
@@ -574,9 +572,7 @@ static int load_devices(struct devs *devices, char *devmap,
        struct mddev_dev *tmpdev;
        int devcnt = 0;
        int nextspare = 0;
-#ifndef MDASSEMBLE
        int bitmap_done = 0;
-#endif
        int most_recent = -1;
        int bestcnt = 0;
        int *best = *bestp;
@@ -592,7 +588,6 @@ static int load_devices(struct devs *devices, char *devmap,
                if (tmpdev->used != 1)
                        continue;
                /* looks like a good enough match to update the super block if needed */
-#ifndef MDASSEMBLE
                if (c->update) {
                        /* prepare useful information in info structures */
                        struct stat stb2;
@@ -602,6 +597,12 @@ static int load_devices(struct devs *devices, char *devmap,
                        if (strcmp(c->update, "uuid") == 0 && !ident->uuid_set)
                                random_uuid((__u8 *)ident->uuid);
 
+                       if (strcmp(c->update, "ppl") == 0 &&
+                           ident->bitmap_fd >= 0) {
+                               pr_err("PPL is not compatible with bitmap\n");
+                               return -1;
+                       }
+
                        dfd = dev_open(devname,
                                       tmpdev->disposition == 'I'
                                       ? O_RDWR : (O_RDWR|O_EXCL));
@@ -677,9 +678,7 @@ static int load_devices(struct devs *devices, char *devmap,
                                else
                                        bitmap_done = 1;
                        }
-               } else
-#endif
-               {
+               } else {
                        dfd = dev_open(devname,
                                       tmpdev->disposition == 'I'
                                       ? O_RDWR : (O_RDWR|O_EXCL));
@@ -1091,7 +1090,6 @@ static int start_array(int mdfd,
                 * it read-only and let the grow code make it writable.
                 */
                int rv;
-#ifndef MDASSEMBLE
                if (content->reshape_active &&
                    !(content->reshape_active & RESHAPE_NO_BACKUP) &&
                    content->delta_disks <= 0) {
@@ -1116,7 +1114,6 @@ static int start_array(int mdfd,
                        rv = sysfs_set_str(content, NULL,
                                           "array_state", "readonly");
                } else
-#endif
                        rv = ioctl(mdfd, RUN_ARRAY, NULL);
                reopen_mddev(mdfd); /* drop O_EXCL */
                if (rv == 0) {
@@ -1471,8 +1468,7 @@ try_again:
                return 1;
        }
        mddev = chosen_name;
-       if (get_linux_version() < 2004000 ||
-           md_get_version(mdfd) < 9000) {
+       if (get_linux_version() < 2004000) {
                pr_err("Assemble requires Linux 2.4 or later, and\n"
                       "     md driver version 0.90.0 or later.\n"
                       "    Upgrade your kernel or try --build\n");
@@ -1501,7 +1497,6 @@ try_again:
                ioctl(mdfd, STOP_ARRAY, NULL);
        }
 
-#ifndef MDASSEMBLE
        if (content != &info) {
                /* This is a member of a container.  Try starting the array. */
                int err;
@@ -1510,7 +1505,7 @@ try_again:
                close(mdfd);
                return err;
        }
-#endif
+
        /* Ok, no bad inconsistancy, we can try updating etc */
        devices = xcalloc(num_devs, sizeof(*devices));
        devmap = xcalloc(num_devs, content->array.raid_disks);
@@ -1663,9 +1658,13 @@ try_again:
                return 1;
        }
        st->ss->getinfo_super(st, content, NULL);
-#ifndef MDASSEMBLE
-       sysfs_init(content, mdfd, NULL);
-#endif
+       if (sysfs_init(content, mdfd, NULL)) {
+               pr_err("Unable to initialize sysfs\n");
+               close(mdfd);
+               free(devices);
+               return 1;
+       }
+
        /* after reload context, store journal_clean in context */
        content->journal_clean = journal_clean;
        for (i=0; i<bestcnt; i++) {
@@ -1751,7 +1750,6 @@ try_again:
         * that was moved aside due to the reshape overwriting live data
         * The code of doing this lives in Grow.c
         */
-#ifndef MDASSEMBLE
        if (content->reshape_active &&
            !(content->reshape_active & RESHAPE_NO_BACKUP)) {
                int err = 0;
@@ -1803,7 +1801,6 @@ try_again:
                        return err;
                }
        }
-#endif
 
        /* Almost ready to actually *do* something */
        /* First, fill in the map, so that udev can find our name
@@ -1866,7 +1863,6 @@ try_again:
        return rv == 2 ? 0 : rv;
 }
 
-#ifndef MDASSEMBLE
 int assemble_container_content(struct supertype *st, int mdfd,
                               struct mdinfo *content, struct context *c,
                               char *chosen_name, int *result)
@@ -1879,7 +1875,10 @@ int assemble_container_content(struct supertype *st, int mdfd,
        char *avail;
        int err;
 
-       sysfs_init(content, mdfd, NULL);
+       if (sysfs_init(content, mdfd, NULL)) {
+               pr_err("Unable to initialize sysfs\n");
+               return 1;
+       }
 
        sra = sysfs_read(mdfd, NULL, GET_VERSION|GET_DEVS);
        if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) {
@@ -1888,7 +1887,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
                    c->readonly &&
                    content->text_version[0] == '/')
                        content->text_version[0] = '-';
-               if (sysfs_set_array(content, md_get_version(mdfd)) != 0) {
+               if (sysfs_set_array(content, 9003) != 0) {
                        sysfs_free(sra);
                        return 1;
                }
@@ -2106,4 +2105,3 @@ int assemble_container_content(struct supertype *st, int mdfd,
        return err;
        /* FIXME should have an O_EXCL and wait for read-auto */
 }
-#endif