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 03/12] DDF: increase seq number when writing meta data
Date: Fri,  1 Mar 2013 23:28:24 +0100	[thread overview]
Message-ID: <1362176913-6804-4-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <1362176913-6804-1-git-send-email-mwilck@arcor.de>

Cleanly increase the seq number when the DDF structures are
written, instead of always setting it back to 1.

Also, make sure that the sequential number of all headers and
VD conf records is the same.

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

diff --git a/super-ddf.c b/super-ddf.c
index 2f75fc3..e165927 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -2377,6 +2377,7 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type,
 			c = (struct vcl *)d->spare;
 
 		if (c) {
+			c->conf.seqnum = ddf->primary.seq;
 			c->conf.crc = calc_crc(&c->conf, conf_size);
 			if (write(fd, &c->conf, conf_size) < 0)
 				break;
@@ -2409,12 +2410,20 @@ static int __write_init_super_ddf(struct supertype *st)
 	int successes = 0;
 	unsigned long long size;
 	char *null_aligned;
+	__u32 seq;
 
 	if (posix_memalign((void**)&null_aligned, 4096, NULL_CONF_SZ) != 0) {
 		return -ENOMEM;
 	}
 	memset(null_aligned, 0xff, NULL_CONF_SZ);
 
+	if (ddf->primary.seq != 0xffffffff)
+		seq = __cpu_to_be32(__be32_to_cpu(ddf->primary.seq)+1);
+	else if (ddf->secondary.seq != 0xffffffff)
+		seq = __cpu_to_be32(__be32_to_cpu(ddf->secondary.seq)+1);
+	else
+		seq = __cpu_to_be32(1);
+
 	/* try to write updated metadata,
 	 * if we catch a failure move on to the next disk
 	 */
@@ -2448,12 +2457,12 @@ static int __write_init_super_ddf(struct supertype *st)
 		else
 			ddf->anchor.secondary_lba =
 				__cpu_to_be64(size - 32*1024*2);
-		ddf->anchor.seq = __cpu_to_be32(1);
 		memcpy(&ddf->primary, &ddf->anchor, 512);
 		memcpy(&ddf->secondary, &ddf->anchor, 512);
 
 		ddf->anchor.openflag = 0xFF; /* 'open' means nothing */
 		ddf->anchor.seq = 0xFFFFFFFF; /* no sequencing in anchor */
+		ddf->secondary.seq = ddf->primary.seq = seq;
 		ddf->anchor.crc = calc_crc(&ddf->anchor, 512);
 
 		if (!__write_ddf_structure(d, ddf, DDF_HEADER_PRIMARY,
-- 
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 ` mwilck [this message]
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 ` [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-4-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).