mdadm/DDF-add_to_super_ddf-be-careful-with-workspace_lba.patch
Neil Brown 78f6e472f9 - DDF-handle-fake-RAIDs-with-changing-subarray-UUIDs.patch
- DDF-compare_super_ddf-fix-sequence-number-check.patch
- Monitor-don-t-set-arrays-dirty-after-transition-to-r.patch
- DDF-add_to_super_ddf-be-careful-with-workspace_lba.patch
- Monitor-write-meta-data-in-readonly-state-sometimes.patch
- Assembe-fix-bug-in-force_array-it-wasn-t-forcing-pro.patch
  Various bugfixes from upstream - several to improve
  DDF support, one which fixes a nasty bug in "--assemble --force".

- DDF-brief_examine_subarrays_ddf-print-array-name.patch
  DDF-factor-out-array-name-generation.patch
  Include name in "-Db" output for DDF
  FATE#316007

OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=96
2013-11-11 00:47:33 +00:00

59 lines
1.9 KiB
Diff

From 105e6e93a2b556560d0275bd5ceb29751de28469 Mon Sep 17 00:00:00 2001
From: "mwilck@arcor.de" <mwilck@arcor.de>
Date: Tue, 24 Sep 2013 19:18:52 +0200
Subject: [PATCH] DDF: add_to_super_ddf: be careful with workspace_lba
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>
Signed-off-by: NeilBrown <neilb@suse.de>
---
super-ddf.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
--- mdadm-3.3.orig/super-ddf.c
+++ mdadm-3.3/super-ddf.c
@@ -2704,6 +2704,31 @@ static unsigned int find_unused_pde(cons
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 super
if (ddf->dlist == NULL ||
be64_to_cpu(ddf->dlist->secondary_lba) != ~(__u64)0)
__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);