From: mwilck@arcor.de
To: neilb@suse.de, linux-raid@vger.kernel.org
Cc: mwilck@arcor.de
Subject: [PATCH 16/27] DDF: use LBA_OFFSET macro instead of lba_offset field
Date: Wed, 3 Jul 2013 22:27:56 +0200 [thread overview]
Message-ID: <1372883287-8859-17-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <1372883287-8859-1-git-send-email-mwilck@arcor.de>
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>
---
super-ddf.c | 32 ++++++++++++--------------------
1 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/super-ddf.c b/super-ddf.c
index 1893f45..f22c0e3 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 */
@@ -1034,9 +1033,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)
@@ -1844,7 +1840,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
@@ -2303,7 +2300,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;
@@ -2371,7 +2369,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;
@@ -2472,7 +2469,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)
@@ -3572,7 +3569,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)
@@ -3611,8 +3607,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);
@@ -3784,8 +3780,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))
@@ -4046,11 +4040,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 |=
@@ -4244,8 +4237,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;
@@ -4568,7 +4559,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
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;
--
1.7.1
next prev parent reply other threads:[~2013-07-03 20:27 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 20:27 DDF/RAID10 patch series mwilck
2013-07-03 20:27 ` [PATCH 01/27] DDF (cleanup): use a common macro for failed searches mwilck
2013-07-03 20:27 ` [PATCH 02/27] DDF: check_secondary: fix treatment of missing BVDs mwilck
2013-07-03 20:27 ` [PATCH 03/27] DDF: load_ddf_headers: use secondary header as fallback mwilck
2013-07-08 5:43 ` NeilBrown
2013-07-08 20:56 ` Martin Wilck
2013-07-03 20:27 ` [PATCH 04/27] DDF: handle "open flag" according to spec mwilck
2013-07-03 20:27 ` [PATCH 05/27] DDF: Implement store_super_ddf mwilck
2013-07-08 5:48 ` NeilBrown
2013-07-10 17:37 ` Martin Wilck
2013-07-15 5:31 ` NeilBrown
2013-07-18 18:48 ` [PATCH 1/3] DDF: increase seq number in ddf_set_updates_pending mwilck
2013-07-18 18:49 ` [PATCH 2/3] DDF: make "null_aligned" a static buffer mwilck
2013-07-18 18:49 ` [PATCH 3/3] DDF: factor out writing super block to single disk mwilck
2013-07-18 18:51 ` [PATCH 05/27] DDF: Implement store_super_ddf Martin Wilck
2013-07-03 20:27 ` [PATCH 06/27] DDF: ddf_open_new: implement minimal consistency check mwilck
2013-07-03 20:27 ` [PATCH 07/27] DDF: find_vdcr: account for secondary RAID level mwilck
2013-07-08 6:16 ` NeilBrown
2013-07-08 21:03 ` Martin Wilck
2013-07-03 20:27 ` [PATCH 08/27] DDF: ddf_set_disk: move status logic to separate function mwilck
2013-07-03 20:27 ` [PATCH 09/27] DDF: get_svd_state: Status logic for secondary RAID level mwilck
2013-07-03 20:27 ` [PATCH 10/27] DDF: allow empty slots in virt disk table mwilck
2013-07-03 20:27 ` [PATCH 11/27] DDF: layout_ddf2md: new DDF->md RAID layout conversion mwilck
2013-07-08 6:48 ` NeilBrown
2013-07-08 21:06 ` Martin Wilck
2013-07-03 20:27 ` [PATCH 12/27] DDF: layout_md2ddf: new md->DDF " mwilck
2013-07-08 6:28 ` NeilBrown
2013-07-03 20:27 ` [PATCH 13/27] DDF: Simplify allocation of "other BVDs" mwilck
2013-07-03 20:27 ` [PATCH 14/27] DDF: init_super_ddf_bvd: initialize other bvds mwilck
2013-07-03 20:27 ` [PATCH 15/27] DDF: validate_geometry_ddf: support RAID10 mwilck
2013-07-03 20:27 ` mwilck [this message]
2013-07-03 20:27 ` [PATCH 17/27] DDF: get_extents: support secondary RAID level mwilck
2013-07-03 20:27 ` [PATCH 18/27] DDF: add_to_super_ddf: allow empty slots in phys disk table mwilck
2013-07-03 20:27 ` [PATCH 19/27] DDF: add_to_super_ddf: Use same amount of workspace as other disks mwilck
2013-07-03 20:28 ` [PATCH 20/27] DDF: add_to_super_ddf: RAID10 changes mwilck
2013-07-03 20:28 ` [PATCH 21/27] DDF: add_to_super_ddf_bvd: use get_svd_state() mwilck
2013-07-03 20:28 ` [PATCH 22/27] DDF: getinfo_super_ddf_bvd: lba_offset calculation for RAID10 mwilck
2013-07-03 20:28 ` [PATCH 23/27] DDF: guid_str: convenience function to print GUID for debugging mwilck
2013-07-03 20:28 ` [PATCH 24/27] DDF: ddf_set_array_state: more meaningful output mwilck
2013-07-03 20:28 ` [PATCH 25/27] DDF: ddf_process_update: handle update of conf records for SVD mwilck
2013-07-03 20:28 ` [PATCH 26/27] DDF: ddf_process_update: Fix vlist treatment for SVDs mwilck
2013-07-03 20:28 ` [PATCH 27/27] tests/10ddf-create: add RAID 10 array mwilck
2013-07-04 10:10 ` DDF/RAID10 patch series NeilBrown
2013-07-08 6:53 ` NeilBrown
2013-07-08 21:50 ` Fixes for the DDF " mwilck
2013-07-08 21:50 ` [PATCH 28/39] test/10-ddf-create: fix comments mwilck
2013-07-08 21:50 ` [PATCH 29/39] Monitor: Don't write metadata in inactive array state mwilck
2013-07-08 21:50 ` [PATCH 30/39] DDF: write_init_super_ddf: don't zero superblocks for subarrays mwilck
2013-07-08 21:50 ` [PATCH 31/39] DDF: implement kill_subarray mwilck
2013-07-08 21:50 ` [PATCH 32/39] DDF: getinfo_super_ddf_bvd: identify disk by refnum mwilck
2013-07-08 21:50 ` [PATCH 33/39] DDF: getinfo_super_ddf_bvd: fix raid_disk calculation mwilck
2013-07-08 21:50 ` [PATCH 34/39] DDF: fix endianness of refnum in debug messages mwilck
2013-07-08 21:50 ` [PATCH 35/39] DDF: add debug message in add_super_ddf_bvd mwilck
2013-07-08 21:50 ` [PATCH 36/39] DDF: ddf_process_update: add debug messages fore adding VDs mwilck
2013-07-08 21:50 ` [PATCH 37/39] DDF: guid_str: more readable output mwilck
2013-07-08 21:50 ` [PATCH 38/39] DDF: ddf_process_update: some more debug messages mwilck
2013-07-08 21:50 ` [PATCH 39/39] DDF: ddf_process_update: Fix updates for SVDs mwilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372883287-8859-17-git-send-email-mwilck@arcor.de \
--to=mwilck@arcor.de \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).