]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
imsm: Remove --dump/--restore implementation
[thirdparty/mdadm.git] / super-ddf.c
index 50197a8f528b93f994d3fb884ccf9141159216d1..7cd5702d81fa3547c3f7f070058ba83509fea883 100644 (file)
@@ -670,8 +670,8 @@ static int layout_md2ddf(const mdu_array_info_t *array,
                        sec_elmnt_count = array->raid_disks / 2;
                        srl = DDF_2SPANNED;
                        prl = DDF_RAID1;
-               } else if (array->raid_disks % 3 == 0
-                          && array->layout == 0x103) {
+               } else if (array->raid_disks % 3 == 0 &&
+                          array->layout == 0x103) {
                        rlq = DDF_RAID1_MULTI;
                        prim_elmnt_count =  cpu_to_be16(3);
                        sec_elmnt_count = array->raid_disks / 3;
@@ -853,8 +853,8 @@ static void *load_section(int fd, struct ddf_super *super, void *buf,
        int dofree = (buf == NULL);
 
        if (check)
-               if (len != 2 && len != 8 && len != 32
-                   && len != 128 && len != 512)
+               if (len != 2 && len != 8 && len != 32 &&
+                   len != 128 && len != 512)
                        return NULL;
 
        if (len > 1024)
@@ -932,14 +932,13 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname)
        if (load_ddf_header(fd, be64_to_cpu(super->anchor.secondary_lba),
                            dsize >> 9,  2,
                            &super->secondary, &super->anchor)) {
-               if (super->active == NULL
-                   || (be32_to_cpu(super->primary.seq)
-                       < be32_to_cpu(super->secondary.seq) &&
-                       !super->secondary.openflag)
-                   || (be32_to_cpu(super->primary.seq)
-                       == be32_to_cpu(super->secondary.seq) &&
-                       super->primary.openflag && !super->secondary.openflag)
-                       )
+               if (super->active == NULL ||
+                   (be32_to_cpu(super->primary.seq)
+                    < be32_to_cpu(super->secondary.seq) &&
+                       !super->secondary.openflag) ||
+                   (be32_to_cpu(super->primary.seq) ==
+                    be32_to_cpu(super->secondary.seq) &&
+                       super->primary.openflag && !super->secondary.openflag))
                        super->active = &super->secondary;
        } else if (devname &&
                   be64_to_cpu(super->anchor.secondary_lba) != ~(__u64)0)
@@ -1731,7 +1730,8 @@ err:
        return 1;
 }
 
-static void detail_super_ddf(struct supertype *st, char *homehost)
+static void detail_super_ddf(struct supertype *st, char *homehost,
+                            char *subarray)
 {
        struct ddf_super *sb = st->sb;
        int cnt = be16_to_cpu(sb->virt->populated_vdes);
@@ -1788,7 +1788,7 @@ static void uuid_of_ddf_subarray(const struct ddf_super *ddf,
        memcpy(uuid, sha, 4*4);
 }
 
-static void brief_detail_super_ddf(struct supertype *st)
+static void brief_detail_super_ddf(struct supertype *st, char *subarray)
 {
        struct mdinfo info;
        char nbuf[64];
@@ -1884,8 +1884,8 @@ static struct vd_config *find_vdcr(struct ddf_super *ddf, unsigned int inst,
                nsec = n / be16_to_cpu(conf->prim_elmnt_count);
                if (conf->sec_elmnt_seq != nsec) {
                        for (ibvd = 1; ibvd < conf->sec_elmnt_count; ibvd++) {
-                               if (v->other_bvds[ibvd-1]->sec_elmnt_seq
-                                   == nsec)
+                               if (v->other_bvds[ibvd-1]->sec_elmnt_seq ==
+                                   nsec)
                                        break;
                        }
                        if (ibvd == conf->sec_elmnt_count)
@@ -1901,7 +1901,7 @@ static struct vd_config *find_vdcr(struct ddf_super *ddf, unsigned int inst,
                return conf;
        }
 bad:
-       pr_err("Could't find disk %d in array %u\n", n, inst);
+       pr_err("Couldn't find disk %d in array %u\n", n, inst);
        return NULL;
 }
 
@@ -2028,8 +2028,8 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
                               be32_to_cpu(ddf->phys->entries[e].refnum) == 0xffffffff)
                                e++;
                        if (i < info->array.raid_disks && e < max &&
-                           !(be16_to_cpu(ddf->phys->entries[e].state)
-                             DDF_Failed))
+                           !(be16_to_cpu(ddf->phys->entries[e].state) &
+                             DDF_Failed))
                                map[i] = 1;
                        else
                                map[i] = 0;
@@ -2114,11 +2114,10 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
        info->resync_start = 0;
        info->reshape_active = 0;
        info->recovery_blocked = 0;
-       if (!(ddf->virt->entries[info->container_member].state
-             & DDF_state_inconsistent)  &&
-           (ddf->virt->entries[info->container_member].init_state
-            & DDF_initstate_mask)
-           == DDF_init_full)
+       if (!(ddf->virt->entries[info->container_member].state &
+             DDF_state_inconsistent) &&
+           (ddf->virt->entries[info->container_member].init_state &
+            DDF_initstate_mask) == DDF_init_full)
                info->resync_start = MaxSector;
 
        uuid_from_super_ddf(st, info->uuid);
@@ -2135,7 +2134,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
        if (map)
                for (j = 0; j < map_disks; j++) {
                        map[j] = 0;
-                       if (j <  info->array.raid_disks) {
+                       if (j < info->array.raid_disks) {
                                int i = find_phys(ddf, vc->conf.phys_refnum[j]);
                                if (i >= 0 &&
                                    (be16_to_cpu(ddf->phys->entries[i].state)
@@ -2883,8 +2882,9 @@ static int add_to_super_ddf(struct supertype *st,
        dd->disk.magic = DDF_PHYS_DATA_MAGIC;
        now = time(0);
        tm = localtime(&now);
-       sprintf(dd->disk.guid, "%8s%04d%02d%02d",
-               T10, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
+       sprintf(dd->disk.guid, "%8s%04d%02d%02d", T10,
+               (__u16)tm->tm_year+1900,
+               (__u8)tm->tm_mon+1, (__u8)tm->tm_mday);
        tptr = (__u32 *)(dd->disk.guid + 16);
        *tptr++ = random32();
        *tptr = random32();
@@ -3513,8 +3513,8 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
                if (minsize == 0)
                        minsize = 8;
                for (dl = ddf->dlist; dl ; dl = dl->next) {
-                       if (find_space(ddf, dl, data_offset, &minsize)
-                           != INVALID_SECTORS)
+                       if (find_space(ddf, dl, data_offset, &minsize) !=
+                           INVALID_SECTORS)
                                dcnt++;
                }
                if (dcnt < raiddisks) {
@@ -3816,13 +3816,13 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray
                        unsigned int iphys;
                        int stt;
 
-                       if (be32_to_cpu(ddf->phys->entries[pd].refnum)
-                           == 0xFFFFFFFF)
+                       if (be32_to_cpu(ddf->phys->entries[pd].refnum) ==
+                           0xffffffff)
                                continue;
 
                        stt = be16_to_cpu(ddf->phys->entries[pd].state);
-                       if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding))
-                           != DDF_Online)
+                       if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding)) !=
+                           DDF_Online)
                                continue;
 
                        i = get_pd_index_from_refnum(
@@ -4006,8 +4006,8 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
                        continue;
 
                if (posix_memalign((void **)&dl1, 512,
-                      sizeof(*dl1) + (first->max_part) * sizeof(dl1->vlist[0]))
-                   != 0) {
+                                  sizeof(*dl1) + (first->max_part) *
+                                  sizeof(dl1->vlist[0])) != 0) {
                        pr_err("could not allocate disk info buffer\n");
                        return 3;
                }
@@ -4207,8 +4207,8 @@ static int get_bvd_state(const struct ddf_super *ddf,
                if (pd < 0)
                        continue;
                st = be16_to_cpu(ddf->phys->entries[pd].state);
-               if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding))
-                   == DDF_Online) {
+               if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding)) ==
+                   DDF_Online) {
                        working++;
                        avail[i] = 1;
                }
@@ -4446,7 +4446,7 @@ static int _kill_subarray_ddf(struct ddf_super *ddf, const char *guid)
        return 0;
 }
 
-static int kill_subarray_ddf(struct supertype *st)
+static int kill_subarray_ddf(struct supertype *st, char *subarray_id)
 {
        struct ddf_super *ddf = st->sb;
        /*
@@ -4618,9 +4618,9 @@ static void ddf_remove_failed(struct ddf_super *ddf)
                    0xFFFFFFFF)
                        continue;
                if (be16_and(ddf->phys->entries[pdnum].state,
-                            cpu_to_be16(DDF_Failed))
-                   && be16_and(ddf->phys->entries[pdnum].state,
-                               cpu_to_be16(DDF_Transition))) {
+                            cpu_to_be16(DDF_Failed)) &&
+                   be16_and(ddf->phys->entries[pdnum].state,
+                            cpu_to_be16(DDF_Transition))) {
                        /* skip this one unless in dlist*/
                        for (dl = ddf->dlist; dl; dl = dl->next)
                                if (dl->pdnum == (int)pdnum)
@@ -5151,8 +5151,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
                vc = (struct vd_config *)(mu->buf
                                          + i_sec * ddf->conf_rec_len * 512);
                for (dl = ddf->dlist; dl; dl = dl->next)
-                       if (dl->major == di->disk.major
-                           && dl->minor == di->disk.minor)
+                       if (dl->major == di->disk.major &&
+                           dl->minor == di->disk.minor)
                                break;
                if (!dl || dl->pdnum < 0) {
                        pr_err("BUG: can't find disk %d (%d/%d)\n",