linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mwilck@arcor.de
To: neilb@suse.de, linux-raid@vger.kernel.org
Cc: mwilck@arcor.de
Subject: [PATCH 4/4] DDF: ddf_activate_spare: fix metadata update for SVDs
Date: Thu, 25 Jul 2013 20:59:13 +0200	[thread overview]
Message-ID: <1374778753-6252-5-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <1374778753-6252-1-git-send-email-mwilck@arcor.de>

Metadata updates for secondary RAID (RAID10) need to cover
all BVDs. Compare with code in write_init_super_ddf().
---
 super-ddf.c |   41 ++++++++++++++++++++++++++++++++---------
 1 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/super-ddf.c b/super-ddf.c
index ae1222c..47074fe 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -4730,6 +4730,7 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
 	struct metadata_update *mu;
 	struct dl *dl;
 	int i;
+	unsigned int j;
 	struct vcl *vcl;
 	struct vd_config *vc;
 	unsigned int n_bvd;
@@ -4902,26 +4903,48 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
 	 * Create a metadata_update record to update the
 	 * phys_refnum and lba_offset values
 	 */
+	vc = find_vdcr(ddf, a->info.container_member, di->disk.raid_disk,
+		       &n_bvd, &vcl);
+	if (vc == NULL)
+		return NULL;
+
 	mu = xmalloc(sizeof(*mu));
 	if (posix_memalign(&mu->space, 512, sizeof(struct vcl)) != 0) {
 		free(mu);
 		mu = NULL;
 	}
-	mu->buf = xmalloc(ddf->conf_rec_len * 512);
-	mu->len = ddf->conf_rec_len * 512;
+
+	mu->len = ddf->conf_rec_len * 512 * vcl->conf.sec_elmnt_count;
+	mu->buf = xmalloc(mu->len);
 	mu->space = NULL;
 	mu->space_list = NULL;
 	mu->next = *updates;
-	vc = find_vdcr(ddf, a->info.container_member, di->disk.raid_disk,
-		       &n_bvd, &vcl);
-	memcpy(mu->buf, vc, ddf->conf_rec_len * 512);
+	memcpy(mu->buf, &vcl->conf, ddf->conf_rec_len * 512);
+	for (j = 1; j < vcl->conf.sec_elmnt_count; j++)
+		memcpy(mu->buf + j * ddf->conf_rec_len * 512,
+		       vcl->other_bvds[j-1], ddf->conf_rec_len * 512);
 
 	vc = (struct vd_config*)mu->buf;
 	for (di = rv ; di ; di = di->next) {
-		vc->phys_refnum[di->disk.raid_disk] =
-			ddf->phys->entries[dl->pdnum].refnum;
-		LBA_OFFSET(ddf, vc)[di->disk.raid_disk]
-			= cpu_to_be64(di->data_offset);
+		unsigned int i_sec, i_prim;
+		i_sec = di->disk.raid_disk
+			/ be16_to_cpu(vcl->conf.prim_elmnt_count);
+		i_prim = di->disk.raid_disk
+			% be16_to_cpu(vcl->conf.prim_elmnt_count);
+		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)
+				break;
+		if (!dl) {
+			pr_err("%s: BUG: can't find disk %d (%d/%d)\n",
+			       __func__, di->disk.raid_disk,
+			       di->disk.major, di->disk.minor);
+			return NULL;
+		}
+		vc->phys_refnum[i_prim] = ddf->phys->entries[dl->pdnum].refnum;
+		LBA_OFFSET(ddf, vc)[i_prim] = cpu_to_be64(di->data_offset);
 	}
 	*updates = mu;
 	return rv;
-- 
1.7.1

  parent reply	other threads:[~2013-07-25 18:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25 18:59 [PATCH 0/4] Basic hotspare handling for RAID10 mwilck
2013-07-25 18:59 ` [PATCH 1/4] DDF: find_vdcr: fix minor bug in debug message mwilck
2013-07-25 18:59 ` [PATCH 2/4] DDF: ddf_activate_spare: Add RAID10 code mwilck
2013-07-25 18:59 ` [PATCH 3/4] DDF: ddf_activate_spare: only activate good drives mwilck
2013-07-25 18:59 ` mwilck [this message]
2013-07-30  1:22 ` [PATCH 0/4] Basic hotspare handling for RAID10 NeilBrown

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=1374778753-6252-5-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).