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 07/12] DDF: container_content_ddf: check for secondary RAID
Date: Fri,  1 Mar 2013 23:28:28 +0100	[thread overview]
Message-ID: <1362176913-6804-8-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <1362176913-6804-1-git-send-email-mwilck@arcor.de>

Check for supportable secondary RAID configurations.
There is currently only one: RAID 10, if the stripe
sizes and Basic volume sizes are all equal.

With this patch, mdadm will not try to start unsupported
secondary RAID level configurations any more.

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

diff --git a/super-ddf.c b/super-ddf.c
index a5080dd..4186038 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3051,6 +3051,74 @@ static int load_container_ddf(struct supertype *st, int fd,
 
 #endif /* MDASSEMBLE */
 
+static int check_secondary(const struct vcl *vc)
+{
+	const struct vd_config *conf = &vc->conf;
+	int i;
+
+	/* The only DDF secondary RAID level md can support is
+	 * RAID 10, if the stripe sizes and Basic volume sizes
+	 * are all equal.
+	 * Other configurations could in theory be supported by exposing
+	 * the BVDs to user space and using device mapper for the secondary
+	 * mapping. So far we don't support that.
+	 */
+
+	__u64 sec_elements[4] = {0, 0, 0, 0};
+#define __set_sec_seen(n) (sec_elements[(n)>>6] |= (1<<((n)&63)))
+#define __was_sec_seen(n) ((sec_elements[(n)>>6] & (1<<((n)&63))) != 0)
+
+	if (vc->other_bvds == NULL) {
+		pr_err("No BVDs for secondary RAID found\n");
+		return -1;
+	}
+	if (conf->prl != DDF_RAID1) {
+		pr_err("Secondary RAID level only supported for mirrored BVD\n");
+		return -1;
+	}
+	if (conf->srl != DDF_2STRIPED && conf->srl != DDF_2SPANNED) {
+		pr_err("Secondary RAID level %d is unsupported\n",
+		       conf->srl);
+		return -1;
+	}
+	__set_sec_seen(conf->sec_elmnt_seq);
+	for (i = 0; i < conf->sec_elmnt_count-1; i++) {
+		const struct vd_config *bvd = vc->other_bvds[i];
+		if (bvd == NULL) {
+			pr_err("BVD %d is missing", i+1);
+			return -1;
+		}
+		if (bvd->srl != conf->srl) {
+			pr_err("Inconsistent secondary RAID level across BVDs\n");
+			return -1;
+		}
+		if (bvd->prl != conf->prl) {
+			pr_err("Different RAID levels for BVDs are unsupported\n");
+			return -1;
+		}
+		if (bvd->prim_elmnt_count != conf->prim_elmnt_count) {
+			pr_err("All BVDs must have the same number of primary elements\n");
+			return -1;
+		}
+		if (bvd->chunk_shift != conf->chunk_shift) {
+			pr_err("Different strip sizes for BVDs are unsupported\n");
+			return -1;
+		}
+		if (bvd->array_blocks != conf->array_blocks) {
+			pr_err("Different BVD sizes are unsupported\n");
+			return -1;
+		}
+		__set_sec_seen(bvd->sec_elmnt_seq);
+	}
+	for (i = 0; i < conf->sec_elmnt_count; i++) {
+		if (!__was_sec_seen(i)) {
+			pr_err("BVD %d is missing\n", i);
+			return -1;
+		}
+	}
+	return 0;
+}
+
 #define NO_SUCH_REFNUM (0xFFFFFFFF)
 static unsigned int get_pd_index_from_refnum(const struct vcl *vc,
 					     __u32 refnum, unsigned int nmax)
@@ -3090,6 +3158,11 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray
 		     *ep != '\0'))
 			continue;
 
+		if (vc->conf.sec_elmnt_count > 1) {
+			if (check_secondary(vc) != 0)
+				continue;
+		}
+
 		this = xcalloc(1, sizeof(*this));
 		this->next = rest;
 		rest = this;
-- 
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 ` mwilck [this message]
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 ` [PATCH 10/12] DDF: add sanity checks in compare_super_ddf mwilck
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-8-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).