summaryrefslogtreecommitdiffstats
path: root/super-ddf.c
diff options
context:
space:
mode:
authormwilck@arcor.de <mwilck@arcor.de>2013-07-03 22:27:56 +0200
committerNeilBrown <neilb@suse.de>2013-07-08 08:48:36 +0200
commit57a666623ddc6e0e2691ca31ed5445a91d8ef30a (patch)
tree29d9f4efffb67d1c14cbffacdaf237b574fd3419 /super-ddf.c
parentDDF: validate_geometry_ddf: support RAID10 (diff)
downloadmdadm-57a666623ddc6e0e2691ca31ed5445a91d8ef30a.tar.xz
mdadm-57a666623ddc6e0e2691ca31ed5445a91d8ef30a.zip
DDF: use LBA_OFFSET macro instead of lba_offset field
Remove the lba_offset field from struct vcl. This field acted as a "cache" for the address of the lba_offset field in the vd_config structure. This isn't useful any more if there are multiple vd_configs in a vcl. This patch also adds __cpu_to_be64 in two places where it has been quite obviously forgotten (ddf_set_disk, ddf_activate_spare). Signed-off-by: Martin Wilck <mwilck@arcor.de> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to '')
-rw-r--r--super-ddf.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/super-ddf.c b/super-ddf.c
index e2f1c44c..3346adff 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -311,6 +311,7 @@ struct vd_config {
/*__u64 lba_offset[0]; LBA offset in each phys. Note extents in a
bvd are always the same size */
};
+#define LBA_OFFSET(ddf, vd) ((__u64 *) &(vd)->phys_refnum[(ddf)->mppe])
/* vd_config.cache_pol[7] is a bitmap */
#define DDF_cache_writeback 1 /* else writethrough */
@@ -407,8 +408,6 @@ struct ddf_super {
char space[512];
struct {
struct vcl *next;
- __u64 *lba_offset; /* location in 'conf' of
- * the lba table */
unsigned int vcnum; /* index into ->virt */
struct vd_config **other_bvds;
__u64 *block_sizes; /* NULL if all the same */
@@ -1037,9 +1036,6 @@ static int load_ddf_local(int fd, struct ddf_super *super,
dl->vlist[vnum++] = vcl;
}
memcpy(&vcl->conf, vd, super->conf_rec_len*512);
- vcl->lba_offset = (__u64*)
- &vcl->conf.phys_refnum[super->mppe];
-
for (i=0; i < max_virt_disks ; i++)
if (memcmp(super->virt->entries[i].guid,
vcl->conf.guid, DDF_GUID_LEN)==0)
@@ -1847,7 +1843,8 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
info->custom_array_size = 0;
if (cd >= 0 && (unsigned)cd < ddf->mppe) {
- info->data_offset = __be64_to_cpu(vc->lba_offset[cd]);
+ info->data_offset =
+ __be64_to_cpu(LBA_OFFSET(ddf, &vc->conf)[cd]);
if (vc->block_sizes)
info->component_size = vc->block_sizes[cd];
else
@@ -2306,7 +2303,8 @@ static struct extent *get_extents(struct ddf_super *ddf, struct dl *dl)
for (j = 0; j < v->conf.prim_elmnt_count; j++)
if (v->conf.phys_refnum[j] == dl->disk.refnum) {
/* This device plays role 'j' in 'v'. */
- rv[n].start = __be64_to_cpu(v->lba_offset[j]);
+ rv[n].start = __be64_to_cpu(
+ LBA_OFFSET(ddf, &v->conf)[j]);
rv[n].size = __be64_to_cpu(v->conf.blocks);
n++;
break;
@@ -2374,7 +2372,6 @@ static int init_super_ddf_bvd(struct supertype *st,
pr_err("%s could not allocate vd_config\n", __func__);
return 0;
}
- vcl->lba_offset = (__u64*) &vcl->conf.phys_refnum[ddf->mppe];
vcl->vcnum = venum;
vcl->block_sizes = NULL; /* FIXME not for CONCAT */
vc = &vcl->conf;
@@ -2475,7 +2472,7 @@ static void add_to_super_ddf_bvd(struct supertype *st,
return;
vc = &ddf->currentconf->conf;
- lba_offset = ddf->currentconf->lba_offset;
+ lba_offset = LBA_OFFSET(ddf, &ddf->currentconf->conf);
ex = get_extents(ddf, dl);
if (!ex)
@@ -3575,7 +3572,6 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray
struct dl *d;
const struct vd_config *bvd;
unsigned int iphys;
- __u64 *lba_offset;
int stt;
if (ddf->phys->entries[pd].refnum == 0xFFFFFFFF)
@@ -3614,8 +3610,8 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray
dev->recovery_start = MaxSector;
dev->events = __be32_to_cpu(ddf->primary.seq);
- lba_offset = (__u64 *)&bvd->phys_refnum[ddf->mppe];
- dev->data_offset = __be64_to_cpu(lba_offset[iphys]);
+ dev->data_offset =
+ __be64_to_cpu(LBA_OFFSET(ddf, bvd)[iphys]);
dev->component_size = __be64_to_cpu(bvd->blocks);
if (d->devname)
strcpy(dev->name, d->devname);
@@ -3787,8 +3783,6 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
free(vl1);
return 3;
}
- vl1->lba_offset = (__u64 *)
- &vl1->conf.phys_refnum[first->mppe];
for (vd = 0; vd < max_vds; vd++)
if (!memcmp(first->virt->entries[vd].guid,
vl1->conf.guid, DDF_GUID_LEN))
@@ -4049,11 +4043,10 @@ 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, vc->phys_refnum[n_bvd], pd);
if ((state & DS_INSYNC) && ! (state & DS_FAULTY)) {
- __u64 *lba_offset;
pd = dl->pdnum; /* FIXME: is this really correct ? */
vc->phys_refnum[n_bvd] = dl->disk.refnum;
- lba_offset = (__u64 *)&vc->phys_refnum[ddf->mppe];
- lba_offset[n_bvd] = mdi->data_offset;
+ LBA_OFFSET(ddf, vc)[n_bvd] =
+ __cpu_to_be64(mdi->data_offset);
ddf->phys->entries[pd].type &=
~__cpu_to_be16(DDF_Global_Spare);
ddf->phys->entries[pd].type |=
@@ -4247,8 +4240,6 @@ static void ddf_process_update(struct supertype *st,
update->space = NULL;
vcl->next = ddf->conflist;
memcpy(&vcl->conf, vc, update->len);
- vcl->lba_offset = (__u64*)
- &vcl->conf.phys_refnum[mppe];
ent = find_vde_by_guid(ddf, vc->guid);
if (ent == DDF_NOTFOUND)
return;
@@ -4396,7 +4387,6 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
int i;
struct vcl *vcl;
struct vd_config *vc;
- __u64 *lba;
unsigned int n_bvd;
for (d = a->info.devs ; d ; d = d->next) {
@@ -4567,11 +4557,11 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
memcpy(mu->buf, vc, ddf->conf_rec_len * 512);
vc = (struct vd_config*)mu->buf;
- lba = (__u64*)&vc->phys_refnum[ddf->mppe];
for (di = rv ; di ; di = di->next) {
vc->phys_refnum[di->disk.raid_disk] =
ddf->phys->entries[dl->pdnum].refnum;
- lba[di->disk.raid_disk] = di->data_offset;
+ LBA_OFFSET(ddf, vc)[di->disk.raid_disk]
+ = __cpu_to_be64(di->data_offset);
}
*updates = mu;
return rv;