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 02/12] DDF: use existing locations for primary and secondary DDF structure
Date: Fri,  1 Mar 2013 23:28:23 +0100	[thread overview]
Message-ID: <1362176913-6804-3-git-send-email-mwilck@arcor.de> (raw)
In-Reply-To: <1362176913-6804-1-git-send-email-mwilck@arcor.de>

Some RAID BIOSes apparently use hard-coded LBA offsets (presumably
from the end of the disk) for the primary and secondary DDF
structure, ignoring the values given in the DDF anchor. This is
broken BIOS behavior, but it will cause any changes made by MD
(e.g. setting the init_state flag after a full initialization)
to be "forgotten" after the next reboot.

This patch fixes this by using the exiting LBA locations if
available. Verified that this fixes MD+LSI Mega Software RAID
BIOS.

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

diff --git a/super-ddf.c b/super-ddf.c
index 7f943cb..2f75fc3 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -421,6 +421,9 @@ struct ddf_super {
 				char *devname;
 				int fd;
 				unsigned long long size; /* sectors */
+				unsigned long long primary_lba; /* sectors */
+				unsigned long long secondary_lba; /* sectors */
+				unsigned long long workspace_lba; /* sectors */
 				int pdnum;	/* index in ->phys */
 				struct spare_assign *spare;
 				void *mdupdate; /* hold metadata update */
@@ -668,6 +671,13 @@ static int load_ddf_local(int fd, struct ddf_super *super,
 	dl->size = 0;
 	if (get_dev_size(fd, devname, &dsize))
 		dl->size = dsize >> 9;
+	/* If the disks have different sizes, the LBAs will differ
+	   between phys disks.
+	   At this point here, the values in super->active must be valid
+	   for this phys disk. */
+	dl->primary_lba = super->active->primary_lba;
+	dl->secondary_lba = super->active->secondary_lba;
+	dl->workspace_lba = super->active->workspace_lba;
 	dl->spare = NULL;
 	for (i = 0 ; i < super->max_part ; i++)
 		dl->vlist[i] = NULL;
@@ -2423,9 +2433,21 @@ static int __write_init_super_ddf(struct supertype *st)
 		 */
 		get_dev_size(fd, NULL, &size);
 		size /= 512;
-		ddf->anchor.workspace_lba = __cpu_to_be64(size - 32*1024*2);
-		ddf->anchor.primary_lba = __cpu_to_be64(size - 16*1024*2);
-		ddf->anchor.secondary_lba = __cpu_to_be64(size - 31*1024*2);
+		if (d->workspace_lba != 0)
+			ddf->anchor.workspace_lba = d->workspace_lba;
+		else
+			ddf->anchor.workspace_lba =
+				__cpu_to_be64(size - 32*1024*2);
+		if (d->primary_lba != 0)
+			ddf->anchor.primary_lba = d->primary_lba;
+		else
+			ddf->anchor.primary_lba =
+				__cpu_to_be64(size - 16*1024*2);
+		if (d->secondary_lba != 0)
+			ddf->anchor.secondary_lba = d->secondary_lba;
+		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);
-- 
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 ` mwilck [this message]
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 ` [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-3-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).