]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
DDF: getinfo_super_ddf_bvd: lba_offset calculation for RAID10
authormwilck@arcor.de <mwilck@arcor.de>
Wed, 3 Jul 2013 20:28:02 +0000 (22:28 +0200)
committerNeilBrown <neilb@suse.de>
Mon, 8 Jul 2013 06:50:37 +0000 (16:50 +1000)
Secondary RAID needs some extra logic here, too.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
super-ddf.c

index 1abd9e5c0d1a691647533fa72e535c125244dd95..0a04519d10ffa8ef7c404968c20d0a97cc2cdeea 100644 (file)
@@ -1832,10 +1832,12 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
        struct ddf_super *ddf = st->sb;
        struct vcl *vc = ddf->currentconf;
        int cd = ddf->currentdev;
+       int n_prim;
        int j;
        struct dl *dl;
        int map_disks = info->array.raid_disks;
        __u32 *cptr;
+       struct vd_config *conf;
 
        memset(info, 0, sizeof(*info));
        if (layout_ddf2md(&vc->conf, &info->array) == -1)
@@ -1847,6 +1849,14 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
        info->array.chunk_size    = 512 << vc->conf.chunk_shift;
        info->custom_array_size   = 0;
 
+       conf = &vc->conf;
+       n_prim = __be16_to_cpu(conf->prim_elmnt_count);
+       if (conf->sec_elmnt_count > 1 && cd >= n_prim) {
+               int ibvd = cd / n_prim - 1;
+               cd %= n_prim;
+               conf = vc->other_bvds[ibvd];
+       }
+
        if (cd >= 0 && (unsigned)cd < ddf->mppe) {
                info->data_offset =
                        __be64_to_cpu(LBA_OFFSET(ddf, &vc->conf)[cd]);