All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Orlowski <lukasz.orlowski@intel.com>
To: neilb@suse.de, dan.j.williams@intel.com
Cc: linux-raid@vger.kernel.org
Subject: [PATCH 2/2] imsm: fix: Fixes metadata after migration from Raid 0 to Raid 10
Date: Fri, 21 Oct 2011 09:47:44 +0200	[thread overview]
Message-ID: <20111021074744.14969.36824.stgit@gklab-128-192.igk.intel.com> (raw)
In-Reply-To: <20111021074643.14969.22068.stgit@gklab-128-192.igk.intel.com>

From: root <root@gklab-128-192.igk.intel.com>

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 <lukasz.orlowski@intel.com>
---
 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.

  parent reply	other threads:[~2011-10-21  7:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21  7:47 [PATCH 0/2] Fixes metadata while migrating from Raid 0 to Raid 10 Lukasz Orlowski
2011-10-21  7:47 ` [PATCH 1/2] imsm: Moves metadata update code for spare activation to separate function Lukasz Orlowski
2011-10-21  7:47 ` Lukasz Orlowski [this message]
2011-10-22  0:50 ` [PATCH 0/2] Fixes metadata while migrating from Raid 0 to Raid 10 NeilBrown

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=20111021074744.14969.36824.stgit@gklab-128-192.igk.intel.com \
    --to=lukasz.orlowski@intel.com \
    --cc=dan.j.williams@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.