]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
mdmon: allow prepare_update to report failure.
[thirdparty/mdadm.git] / super-ddf.c
index 0c714225df5283f2fc02a3909f73b01f145ae5b4..1e43ca26f8858b45f8d0ac85c67717444ac00862 100644 (file)
@@ -30,6 +30,7 @@
 #include "mdmon.h"
 #include "sha1.h"
 #include <values.h>
+#include <stddef.h>
 
 /* a non-official T10 name for creation GUIDs */
 static char T10[] = "Linux-MD";
@@ -536,10 +537,6 @@ static int init_super_ddf_bvd(struct supertype *st,
                              char *name, char *homehost,
                              int *uuid, unsigned long long data_offset);
 
-#ifndef offsetof
-#define offsetof(t,f) ((size_t)&(((t*)0)->f))
-#endif
-
 #if DEBUG
 static void pr_state(struct ddf_super *ddf, const char *msg)
 {
@@ -1761,6 +1758,7 @@ static void detail_super_ddf(struct supertype *st, char *homehost)
        printf("  Virtual Disks : %d\n", cnt);
        printf("\n");
 }
+#endif
 
 static const char *vendors_with_variable_volume_UUID[] = {
        "LSI      ",
@@ -1807,6 +1805,7 @@ static void uuid_of_ddf_subarray(const struct ddf_super *ddf,
        memcpy(uuid, sha, 4*4);
 }
 
+#ifndef MDASSEMBLE
 static void brief_detail_super_ddf(struct supertype *st)
 {
        struct mdinfo info;
@@ -2077,7 +2076,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
        int cd = ddf->currentdev;
        int n_prim;
        int j;
-       struct dl *dl;
+       struct dl *dl = NULL;
        int map_disks = info->array.raid_disks;
        __u32 *cptr;
        struct vd_config *conf;
@@ -3435,16 +3434,8 @@ static int validate_geometry_ddf(struct supertype *st,
         */
        fd = open(dev, O_RDONLY|O_EXCL, 0);
        if (fd >= 0) {
-               sra = sysfs_read(fd, NULL, GET_VERSION);
                close(fd);
-               if (sra && sra->array.major_version == -1 &&
-                   strcmp(sra->text_version, "ddf") == 0) {
-                       /* load super */
-                       /* find space for 'n' devices. */
-                       /* remember the devices */
-                       /* Somehow return the fact that we have enough */
-               }
-
+               /* Just a bare device, no good to us */
                if (verbose)
                        pr_err("ddf: Cannot create this array "
                               "on device %s - a container is required.\n",
@@ -3590,7 +3581,6 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
        maxsize = ULLONG_MAX;
        find_space(ddf, dl, data_offset, &maxsize);
        *freesize = maxsize;
-       // FIXME here I am
 
        return 1;
 }
@@ -3739,7 +3729,7 @@ static int check_secondary(const struct vcl *vc)
        }
        for (i = 0; i < conf->sec_elmnt_count; i++) {
                if (!__was_sec_seen(i)) {
-                       pr_err("BVD %d is missing\n", i);
+                       /* pr_err("BVD %d is missing\n", i); */
                        return -1;
                }
        }
@@ -4403,8 +4393,9 @@ static void ddf_set_disk(struct active_array *a, int n, int state)
                dprintf("%s: array %u disk %u ref %08x pd %d\n",
                        __func__, inst, n_bvd,
                        be32_to_cpu(vc->phys_refnum[n_bvd]), pd);
-               if ((state & DS_INSYNC) && ! (state & DS_FAULTY)) {
-                       pd = dl->pdnum; /* FIXME: is this really correct ? */
+               if ((state & DS_INSYNC) && ! (state & DS_FAULTY) &&
+                   dl->pdnum >= 0) {
+                       pd = dl->pdnum;
                        vc->phys_refnum[n_bvd] = dl->disk.refnum;
                        LBA_OFFSET(ddf, vc)[n_bvd] =
                                cpu_to_be64(mdi->data_offset);
@@ -4597,10 +4588,10 @@ static void ddf_process_phys_update(struct supertype *st,
                        if (dl->pdnum == (signed)ent) {
                                close(dl->fd);
                                dl->fd = -1;
-                               /* FIXME this doesn't free
-                                * dl->devname */
-                               update->space = dl;
                                *dlp = dl->next;
+                               update->space = dl->devname;
+                               *(void**)dl = update->space_list;
+                               update->space_list = (void**)dl;
                                break;
                        }
                }
@@ -4915,8 +4906,8 @@ static void ddf_process_update(struct supertype *st,
        /* case DDF_SPARE_ASSIGN_MAGIC */
 }
 
-static void ddf_prepare_update(struct supertype *st,
-                              struct metadata_update *update)
+static int ddf_prepare_update(struct supertype *st,
+                             struct metadata_update *update)
 {
        /* This update arrived at managemon.
         * We are about to pass it to monitor.
@@ -4931,15 +4922,17 @@ static void ddf_prepare_update(struct supertype *st,
                                   offsetof(struct vcl, conf)
                                   + ddf->conf_rec_len * 512) != 0) {
                        update->space = NULL;
-                       return;
+                       return 0;
                }
                vcl = update->space;
                vcl->conf.sec_elmnt_count = conf->sec_elmnt_count;
                if (alloc_other_bvds(ddf, vcl) != 0) {
                        free(update->space);
                        update->space = NULL;
+                       return 0;
                }
        }
+       return 1;
 }
 
 /*