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 10/12] DDF: add sanity checks in compare_super_ddf
Date: Fri,  1 Mar 2013 23:28:31 +0100	[thread overview]
Message-ID: <1362176913-6804-11-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <1362176913-6804-1-git-send-email-mwilck@arcor.de>

Besides container GUID, also check seqnum, physical and virtual
disk numbers, and check match between local and global sections.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
---
 super-ddf.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/super-ddf.c b/super-ddf.c
index 4c3e6f4..56c9721 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3371,6 +3371,9 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
 	 */
 	struct ddf_super *first = st->sb;
 	struct ddf_super *second = tst->sb;
+	struct dl *dl2;
+	struct vcl *vl2;
+	unsigned int max_vds, max_pds, pd, vd;
 
 	if (!first) {
 		st->sb = tst->sb;
@@ -3381,7 +3384,46 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
 	if (memcmp(first->anchor.guid, second->anchor.guid, DDF_GUID_LEN) != 0)
 		return 2;
 
+	if (first->anchor.seq != second->anchor.seq) {
+		dprintf("%s: sequence number mismatch %u/%u\n", __func__,
+			__be32_to_cpu(first->anchor.seq),
+			__be32_to_cpu(second->anchor.seq));
+		return 3;
+	}
+	if (first->max_part != second->max_part ||
+	    first->phys->used_pdes != second->phys->used_pdes ||
+	    first->virt->populated_vdes != second->virt->populated_vdes) {
+		dprintf("%s: PD/VD number mismatch\n", __func__);
+		return 3;
+	}
+
+	max_pds =  __be16_to_cpu(first->phys->used_pdes);
+	for (dl2 = second->dlist; dl2; dl2 = dl2->next) {
+		for (pd = 0; pd < max_pds; pd++)
+			if (first->phys->entries[pd].refnum == dl2->disk.refnum)
+				break;
+		if (pd == max_pds) {
+			dprintf("%s: no match for disk %08x\n", __func__,
+				__be32_to_cpu(dl2->disk.refnum));
+			return 3;
+		}
+	}
+
+	max_vds = __be16_to_cpu(first->active->max_vd_entries);
+	for (vl2 = second->conflist; vl2; vl2 = vl2->next) {
+		if (vl2->conf.magic != DDF_VD_CONF_MAGIC)
+			continue;
+		for (vd = 0; vd < max_vds; vd++)
+			if (!memcmp(first->virt->entries[vd].guid,
+				    vl2->conf.guid, DDF_GUID_LEN))
+				break;
+		if (vd == max_vds) {
+			dprintf("%s: no match for VD config\n", __func__);
+			return 3;
+		}
+	}
 	/* FIXME should I look at anything else? */
+
 	return 0;
 }
 
-- 
1.7.3.4

  parent reply	other threads:[~2013-03-01 22:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01 22:28 DDF / RAID10 patch series for mdadm mwilck
2013-03-01 22:28 ` [PATCH 01/12] DDF: cleanly save the secondary DDF structure mwilck
2013-03-01 22:28 ` [PATCH 02/12] DDF: use existing locations for primary and " mwilck
2013-03-01 22:28 ` [PATCH 03/12] DDF: increase seq number when writing meta data mwilck
2013-03-01 22:28 ` [PATCH 04/12] DDF: added other_bvd to struct vcl mwilck
2013-03-01 22:28 ` [PATCH 05/12] DDF: load_ddf_local: store VD conf for other BVDs mwilck
2013-03-01 22:28 ` [PATCH 06/12] DDF: container_content_ddf: change array disk search loop mwilck
2013-03-01 22:28 ` [PATCH 07/12] DDF: container_content_ddf: check for secondary RAID mwilck
2013-03-01 22:28 ` [PATCH 08/12] DDF: container_content_ddf: handle RAID layout for RAID10 mwilck
2013-03-01 22:28 ` [PATCH 09/12] DDF: __write_init_super_ddf: use correct VD conf mwilck
2013-03-01 22:28 ` mwilck [this message]
2013-03-01 22:28 ` [PATCH 11/12] DDF: compare_super_ddf: merge local info of other superblock mwilck
2013-03-01 22:28 ` [PATCH 12/12] Detail.c: call load_container for container subarrays mwilck
2013-03-02  7:47   ` Paul Menzel
2013-03-04  5:22 ` DDF / RAID10 patch series for mdadm NeilBrown
2013-03-06 18:26   ` Martin Wilck

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=1362176913-6804-11-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).