linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix mdadm --add for LSI fake RAID
@ 2013-09-24 17:18 mwilck
  2013-09-24 17:18 ` [PATCH 1/2] DDF: add_to_super_ddf: leave invalid secondary_lba untouched mwilck
  2013-09-24 17:18 ` [PATCH 2/2] DDF: add_to_super_ddf: be careful with workspace_lba mwilck
  0 siblings, 2 replies; 4+ messages in thread
From: mwilck @ 2013-09-24 17:18 UTC (permalink / raw)
  To: neilb, linux-raid; +Cc: mwilck

These patches hopefully solve the problem reported by
Francis Moreau in the thread "mdadm 3.3 fails to kick out non
fresh disk": A disk set failed and removed from a LSI DDF fake 
RAID can't be re-added any more.

Martin Wilck (2):
  DDF: add_to_super_ddf: leave invalid secondary_lba untouched
  DDF: add_to_super_ddf: be careful with workspace_lba

 super-ddf.c |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] DDF: add_to_super_ddf: leave invalid secondary_lba untouched
  2013-09-24 17:18 [PATCH 0/2] Fix mdadm --add for LSI fake RAID mwilck
@ 2013-09-24 17:18 ` mwilck
  2013-09-24 18:13   ` [PATCH 1/2] *DO NOT APPLY* " Martin Wilck
  2013-09-24 17:18 ` [PATCH 2/2] DDF: add_to_super_ddf: be careful with workspace_lba mwilck
  1 sibling, 1 reply; 4+ messages in thread
From: mwilck @ 2013-09-24 17:18 UTC (permalink / raw)
  To: neilb, linux-raid; +Cc: mwilck

If the current DDF structure doesn't have a secondary header,
don't set it.

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

diff --git a/super-ddf.c b/super-ddf.c
index 002b271..3e13ff0 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -2822,8 +2822,9 @@ static int add_to_super_ddf(struct supertype *st,
 	} while (0)
 	__calc_lba(dd, ddf->dlist, workspace_lba, 32);
 	__calc_lba(dd, ddf->dlist, primary_lba, 16);
-	if (ddf->dlist == NULL ||
-	    be64_to_cpu(ddf->dlist->secondary_lba) != ~(__u64)0)
+	if (be64_to_cpu(ddf->active->secondary_lba) == ~(__u64)0)
+		dd->secondary_lba = ddf->active->secondary_lba;
+	else
 		__calc_lba(dd, ddf->dlist, secondary_lba, 32);
 	pde->config_size = dd->workspace_lba;
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] DDF: add_to_super_ddf: be careful with workspace_lba
  2013-09-24 17:18 [PATCH 0/2] Fix mdadm --add for LSI fake RAID mwilck
  2013-09-24 17:18 ` [PATCH 1/2] DDF: add_to_super_ddf: leave invalid secondary_lba untouched mwilck
@ 2013-09-24 17:18 ` mwilck
  1 sibling, 0 replies; 4+ messages in thread
From: mwilck @ 2013-09-24 17:18 UTC (permalink / raw)
  To: neilb, linux-raid; +Cc: mwilck

Some vendor DDF structures interpret workspace_lba
very differently then us. Make a sanity check on the value
before using it for config_size.

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

diff --git a/super-ddf.c b/super-ddf.c
index 3e13ff0..7711f96 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -2703,6 +2703,31 @@ static unsigned int find_unused_pde(const struct ddf_super *ddf)
 	return DDF_NOTFOUND;
 }
 
+static void _set_config_size(struct phys_disk_entry *pde, const struct dl *dl)
+{
+	__u64 cfs, t;
+	cfs = min(dl->size - 32*1024*2ULL, be64_to_cpu(dl->primary_lba));
+	t = be64_to_cpu(dl->secondary_lba);
+	if (t != ~(__u64)0)
+		cfs = min(cfs, t);
+	/*
+	 * Some vendor DDF structures interpret workspace_lba
+	 * very differently then us. Make a sanity check on the value.
+	 */
+	t = be64_to_cpu(dl->workspace_lba);
+	if (t < cfs) {
+		__u64 wsp = cfs - t;
+		if (wsp > 1024*1024*2ULL && wsp > dl->size / 16) {
+			pr_err("%s: %x:%x: workspace size 0x%llx too big, ignoring\n",
+			       __func__, dl->major, dl->minor, wsp);
+		} else
+			cfs = t;
+	}
+	pde->config_size = cpu_to_be64(cfs);
+	dprintf("%s: %x:%x config_size %llx, DDF structure is %llx blocks\n",
+		__func__, dl->major, dl->minor, cfs, dl->size-cfs);
+}
+
 /* add a device to a container, either while creating it or while
  * expanding a pre-existing container
  */
@@ -2826,7 +2851,7 @@ static int add_to_super_ddf(struct supertype *st,
 		dd->secondary_lba = ddf->active->secondary_lba;
 	else
 		__calc_lba(dd, ddf->dlist, secondary_lba, 32);
-	pde->config_size = dd->workspace_lba;
+	_set_config_size(pde, dd);
 
 	sprintf(pde->path, "%17.17s","Information: nil") ;
 	memset(pde->pad, 0xff, 6);
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] *DO NOT APPLY* DDF: add_to_super_ddf: leave invalid secondary_lba untouched
  2013-09-24 17:18 ` [PATCH 1/2] DDF: add_to_super_ddf: leave invalid secondary_lba untouched mwilck
@ 2013-09-24 18:13   ` Martin Wilck
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Wilck @ 2013-09-24 18:13 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

Plesse *do not* apply this patch. The next one
([PATCH 2/2] DDF: add_to_super_ddf: be careful with workspace_lba) is
good though.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-24 18:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-24 17:18 [PATCH 0/2] Fix mdadm --add for LSI fake RAID mwilck
2013-09-24 17:18 ` [PATCH 1/2] DDF: add_to_super_ddf: leave invalid secondary_lba untouched mwilck
2013-09-24 18:13   ` [PATCH 1/2] *DO NOT APPLY* " Martin Wilck
2013-09-24 17:18 ` [PATCH 2/2] DDF: add_to_super_ddf: be careful with workspace_lba mwilck

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).