Thread (4 messages) 4 messages, 2 authors, 2011-10-22
STALE5354d

[PATCH 2/2] imsm: fix: Fixes metadata after migration from Raid 0 to Raid 10

From: Lukasz Orlowski <hidden>
Date: 2011-10-21 07:47:44
Subsystem: the rest · Maintainer: Linus Torvalds

From: root <redacted>

After migration from Raid 0 to Raid 10, the metadata is incorrect,
leaving one mirror disk marked as spare and one missing disk as a member
of the array.
The reason is that the metadata update code for spare activation
procedure takes into account one spare disk only, not checking
the following ones.

Signed-off-by: Lukasz Orlowski <redacted>
---
 super-intel.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index c669135..dbac50a 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6994,8 +6994,15 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 	struct dl *dl;
 	unsigned int found;
 	int failed;
-	int victim = get_imsm_disk_idx(dev, u->slot, -1);
+	int victim;
 	int i;
+	int second_map_created = 0;
+
+	for (; u; u = u->next) {
+		victim = get_imsm_disk_idx(dev, u->slot, -1);
+
+		if (victim < 0)
+			return 0;
 
 		for (dl = super->disks; dl; dl = dl->next)
 			if (dl == u->dl)
@@ -7032,8 +7039,12 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 
 		/* mark rebuild */
 		to_state = imsm_check_degraded(super, dev, failed);
-		map->map_state = IMSM_T_STATE_DEGRADED;
-		migrate(dev, super, to_state, MIGR_REBUILD);
+		if (!second_map_created) {
+			second_map_created = 1;
+			map->map_state = IMSM_T_STATE_DEGRADED;
+			migrate(dev, super, to_state, MIGR_REBUILD);
+		} else
+			map->map_state = to_state;
 		migr_map = get_imsm_map(dev, 1);
 		set_imsm_ord_tbl_ent(map, u->slot, dl->index);
 		set_imsm_ord_tbl_ent(migr_map, u->slot,
@@ -7079,6 +7090,7 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 						break;
 			imsm_delete(super, dlp, victim);
 		}
+	}
 
 	return 1;
 }

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
z siedziba w Gdansku
ul. Slowackiego 173
80-298 Gdansk

Sad Rejonowy Gdansk Polnoc w Gdansku, 
VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, 
numer KRS 101882

NIP 957-07-52-316
Kapital zakladowy 200.000 zl

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help