linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Array degradation during reshape and rebuild (cont.)
@ 2011-12-07 12:57 Adam Kwolek
  2011-12-07 12:57 ` [PATCH 1/9] imsm: FIX: Remove longer map request Adam Kwolek
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:57 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

The following series adds implementation details for array
degradation during reshape and rebuild/initialization.

Series fixes problems in handling degradation during rebuild
in imsm metadata and fixes problems noticed in applied changes..

Failing disks using sysfs (echo 1 > /sys/block/sdX/device/delete)
mdadm does his job correctly.
The problem is when disks are pulled physically from system.
As workaround BBM disabling can be used /sent previously/.


BR
Adam
  

---

Adam Kwolek (9):
      imsm: FIX: Use defines for device map access
      imsm: FIX: Check correct slots on disk failure
      imsm: FIX: Finish rebuild and initialization when missing drive is handled
      imsm: FIX: Mark failure for rebuild
      imsm: FIX: Add array map state transition for failures during initialization
      imsm: FIX: Do not allow spare activation during rebuild
      imsm: Function imsm_set_disk() rework
      imsm: FIX: Correct ords merging in end_migration()
      imsm: FIX: Remove longer map request


 super-intel.c |  475 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 285 insertions(+), 190 deletions(-)

-- 
Signature

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

* [PATCH 1/9] imsm: FIX: Remove longer map request
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
@ 2011-12-07 12:57 ` Adam Kwolek
  2011-12-07 12:57 ` [PATCH 2/9] imsm: FIX: Correct ords merging in end_migration() Adam Kwolek
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:57 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

We shouldn't use longer map. mdadm should know what map is accessed
at the moment.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 21aa516..9b3d6be 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -667,12 +667,9 @@ struct imsm_map *get_imsm_map(struct imsm_dev *dev, int second_map)
 {
 	/* A device can have 2 maps if it is in the middle of a migration.
 	 * If second_map is:
-	 *    MAP_0 or
-	 *    0   - we return the first map
-	 *    MAP_1 or
-	 *    1   - we return the second map if it exists, else NULL
+	 *    MAP_0 or 0   - we return the first map
+	 *    MAP_1 or 1   - we return the second map if it exists, else NULL
 	 *   -1   - we return the second map if it exists, else the first
-	 *   -2   - we return longer map /excluding uninitialized state/
 	 */
 	struct imsm_map *map = &dev->vol.map[0];
 	struct imsm_map *map2 = NULL;
@@ -692,12 +689,6 @@ struct imsm_map *get_imsm_map(struct imsm_dev *dev, int second_map)
 		if (map2)
 			map = map2;
 		break;
-	case -2:
-		if (map2
-		    && map2->map_state != IMSM_T_STATE_UNINITIALIZED
-		    && map2->num_members > map->num_members)
-			map = map2;
-		break;
 	default:
 		map = NULL;
 	}
@@ -6421,7 +6412,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 
 	dprintf("imsm: set_disk %d:%x\n", n, state);
 
-	ord = get_imsm_ord_tbl_ent(dev, n, -2);
+	ord = get_imsm_ord_tbl_ent(dev, n, 0);
 	disk = get_imsm_disk(super, ord_to_idx(ord));
 
 	/* check for new failures */


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

* [PATCH 2/9] imsm: FIX: Correct ords merging in end_migration()
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
  2011-12-07 12:57 ` [PATCH 1/9] imsm: FIX: Remove longer map request Adam Kwolek
@ 2011-12-07 12:57 ` Adam Kwolek
  2011-12-07 12:57 ` [PATCH 3/9] imsm: Function imsm_set_disk() rework Adam Kwolek
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:57 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

Ord's merging should occur when rebuild finishes and final state is other
than expected only /additional failures occur during rebuild/.
Exclude array initialization.
Merging ords on migration finish should never happen.
Any failure during migration should be immediately placed in first
/current/ map, so no merge is necessary.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |   45 +++++++++++++++++++++++++++++----------------
 1 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 9b3d6be..8f075e0 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -3128,7 +3128,8 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super,
 	src->map_state = to_state;
 }
 
-static void end_migration(struct imsm_dev *dev, __u8 map_state)
+static void end_migration(struct imsm_dev *dev, struct intel_super *super,
+			  __u8 map_state)
 {
 	struct imsm_map *map = get_imsm_map(dev, 0);
 	struct imsm_map *prev = get_imsm_map(dev, dev->vol.migr_state);
@@ -3139,16 +3140,28 @@ static void end_migration(struct imsm_dev *dev, __u8 map_state)
 	 *
 	 * FIXME add support for raid-level-migration
 	 */
-	for (i = 0; i < prev->num_members; i++)
-		for (j = 0; j < map->num_members; j++)
-			/* during online capacity expansion
-			 * disks position can be changed if takeover is used
-			 */
-			if (ord_to_idx(map->disk_ord_tbl[j]) ==
-			    ord_to_idx(prev->disk_ord_tbl[i])) {
-				map->disk_ord_tbl[j] |= prev->disk_ord_tbl[i];
-				break;
-			}
+	if ((map_state != map->map_state) && (is_gen_migration(dev) == 0) &&
+		(prev->map_state != IMSM_T_STATE_UNINITIALIZED)) {
+		/* when final map state is other than expected
+		 * merge maps (not for migration)
+		 */
+		int failed;
+
+		for (i = 0; i < prev->num_members; i++)
+			for (j = 0; j < map->num_members; j++)
+				/* during online capacity expansion
+				 * disks position can be changed
+				 * if takeover is used
+				 */
+				if (ord_to_idx(map->disk_ord_tbl[j]) ==
+				    ord_to_idx(prev->disk_ord_tbl[i])) {
+					map->disk_ord_tbl[j] |=
+						prev->disk_ord_tbl[i];
+					break;
+				}
+		failed = imsm_count_failed(super, dev, MAP_0);
+		map_state = imsm_check_degraded(super, dev, failed, MAP_0);
+	}
 
 	dev->vol.migr_state = 0;
 	set_migr_type(dev, 0);
@@ -6335,7 +6348,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
 		 */
 		if (is_resyncing(dev)) {
 			dprintf("imsm: mark resync done\n");
-			end_migration(dev, map_state);
+			end_migration(dev, super, map_state);
 			super->updates_pending++;
 			a->last_checkpoint = 0;
 		}
@@ -6434,7 +6447,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 
 	/* check if recovery complete, newly degraded, or failed */
 	if (map_state == IMSM_T_STATE_NORMAL && is_rebuilding(dev)) {
-		end_migration(dev, map_state);
+		end_migration(dev, super, map_state);
 		map = get_imsm_map(dev, 0);
 		map->failed_disk_num = ~0;
 		super->updates_pending++;
@@ -6449,7 +6462,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 	} else if (map_state == IMSM_T_STATE_FAILED &&
 		   map->map_state != map_state) {
 		dprintf("imsm: mark failed\n");
-		end_migration(dev, map_state);
+		end_migration(dev, super, map_state);
 		super->updates_pending++;
 		a->last_checkpoint = 0;
 	} else if (is_gen_migration(dev)) {
@@ -6459,14 +6472,14 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 		case IMSM_T_STATE_NORMAL:
 			dprintf("normal\n");
 			if (a->last_checkpoint >= a->info.component_size)
-				end_migration(dev, map_state);
+				end_migration(dev, super, map_state);
 			map = get_imsm_map(dev, 0);
 			map->failed_disk_num = ~0;
 			break;
 		case IMSM_T_STATE_DEGRADED:
 			dprintf("degraded\n");
 			if (a->last_checkpoint >= a->info.component_size)
-				end_migration(dev, map_state);
+				end_migration(dev, super, map_state);
 			else
 				manage_second_map(super, dev);
 			break;


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

* [PATCH 3/9] imsm: Function imsm_set_disk() rework
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
  2011-12-07 12:57 ` [PATCH 1/9] imsm: FIX: Remove longer map request Adam Kwolek
  2011-12-07 12:57 ` [PATCH 2/9] imsm: FIX: Correct ords merging in end_migration() Adam Kwolek
@ 2011-12-07 12:57 ` Adam Kwolek
  2011-12-07 12:58 ` [PATCH 4/9] imsm: FIX: Do not allow spare activation during rebuild Adam Kwolek
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:57 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

Rework is needed to map state transition part to allow easier code reading.
After rework it is easy to find out what can happen in what map state
transition.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |   98 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 8f075e0..c6509af 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6446,49 +6446,83 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 	map_state = imsm_check_degraded(super, dev, failed, MAP_0);
 
 	/* check if recovery complete, newly degraded, or failed */
-	if (map_state == IMSM_T_STATE_NORMAL && is_rebuilding(dev)) {
-		end_migration(dev, super, map_state);
-		map = get_imsm_map(dev, 0);
-		map->failed_disk_num = ~0;
-		super->updates_pending++;
-		a->last_checkpoint = 0;
-	} else if (map_state == IMSM_T_STATE_DEGRADED &&
-		   map->map_state != map_state &&
-		   !dev->vol.migr_state) {
-		dprintf("imsm: mark degraded\n");
-		map->map_state = map_state;
-		super->updates_pending++;
-		a->last_checkpoint = 0;
-	} else if (map_state == IMSM_T_STATE_FAILED &&
-		   map->map_state != map_state) {
-		dprintf("imsm: mark failed\n");
-		end_migration(dev, super, map_state);
-		super->updates_pending++;
-		a->last_checkpoint = 0;
-	} else if (is_gen_migration(dev)) {
-		dprintf("imsm: Detected General Migration in state: ");
-
-		switch (map_state) {
-		case IMSM_T_STATE_NORMAL:
-			dprintf("normal\n");
+	dprintf("imsm: Detected transition to state ");
+	switch (map_state) {
+	case IMSM_T_STATE_NORMAL: /* transition to normal state */
+		dprintf("normal: ");
+		if (is_rebuilding(dev)) {
+			dprintf("while rebuilding");
+			end_migration(dev, super, map_state);
+			map = get_imsm_map(dev, 0);
+			map->failed_disk_num = ~0;
+			super->updates_pending++;
+			a->last_checkpoint = 0;
+			break;
+		}
+		if (is_gen_migration(dev)) {
+			dprintf("while general migration");
 			if (a->last_checkpoint >= a->info.component_size)
 				end_migration(dev, super, map_state);
+			else
+				map->map_state = map_state;
 			map = get_imsm_map(dev, 0);
 			map->failed_disk_num = ~0;
+			super->updates_pending++;
 			break;
-		case IMSM_T_STATE_DEGRADED:
-			dprintf("degraded\n");
+		}
+	break;
+	case IMSM_T_STATE_DEGRADED: /* transition to degraded state */
+		dprintf("degraded: ");
+		if ((map->map_state != map_state) &&
+		    !dev->vol.migr_state) {
+			dprintf("mark degraded");
+			map->map_state = map_state;
+			super->updates_pending++;
+			a->last_checkpoint = 0;
+			break;
+		}
+		if (is_rebuilding(dev)) {
+			dprintf("while rebuilding.");
+			if (map->map_state != map_state)  {
+				dprintf(" Map state change");
+				end_migration(dev, super, map_state);
+				super->updates_pending++;
+			}
+			break;
+		}
+		if (is_gen_migration(dev)) {
+			dprintf("while general migration");
 			if (a->last_checkpoint >= a->info.component_size)
 				end_migration(dev, super, map_state);
-			else
+			else {
+				map->map_state = map_state;
 				manage_second_map(super, dev);
+			}
+			super->updates_pending++;
 			break;
-		default:
-			dprintf("failed\n");
 		}
-		map->map_state = map_state;
-		super->updates_pending++;
+	break;
+	case IMSM_T_STATE_FAILED: /* transition to failed state */
+		dprintf("failed: ");
+		if (is_gen_migration(dev)) {
+			dprintf("while general migration");
+			map->map_state = map_state;
+			super->updates_pending++;
+			break;
+		}
+		if (map->map_state != map_state) {
+			dprintf("mark failed");
+			end_migration(dev, super, map_state);
+			super->updates_pending++;
+			a->last_checkpoint = 0;
+			break;
+		}
+	break;
+	default:
+		dprintf("state %i\n", map_state);
 	}
+	dprintf("\n");
+
 }
 
 static int store_imsm_mpb(int fd, struct imsm_super *mpb)


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

* [PATCH 4/9] imsm: FIX: Do not allow spare activation during rebuild
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (2 preceding siblings ...)
  2011-12-07 12:57 ` [PATCH 3/9] imsm: Function imsm_set_disk() rework Adam Kwolek
@ 2011-12-07 12:58 ` Adam Kwolek
  2011-12-07 12:58 ` [PATCH 5/9] imsm: FIX: Add array map state transition for failures during initialization Adam Kwolek
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:58 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

Do not allow for spare device activation while rebuild is in progress,
when additional degradation occur.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index c6509af..973b22f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6784,6 +6784,14 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
 	if (imsm_reshape_blocks_arrays_changes(super))
 			return NULL;
 
+	/* Cannot activate another spare if rebuild is in progress already
+	 */
+	if (is_rebuilding(dev)) {
+		dprintf("imsm: No spare activation allowed. "
+			"Rebuild in progress already.\n");
+		return NULL;
+	}
+
 	if (a->info.array.level == 4)
 		/* No repair for takeovered array
 		 * imsm doesn't support raid4


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

* [PATCH 5/9] imsm: FIX: Add array map state transition for failures during initialization
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (3 preceding siblings ...)
  2011-12-07 12:58 ` [PATCH 4/9] imsm: FIX: Do not allow spare activation during rebuild Adam Kwolek
@ 2011-12-07 12:58 ` Adam Kwolek
  2011-12-07 12:58 ` [PATCH 6/9] imsm: FIX: Mark failure for rebuild Adam Kwolek
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:58 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

During initialization disk failure can occur also. Add code for such case
in imsm_set_disk() to support such event.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 973b22f..217a196 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5718,6 +5718,25 @@ static int is_rebuilding(struct imsm_dev *dev)
 		return 0;
 }
 
+static int is_initializing(struct imsm_dev *dev)
+{
+	struct imsm_map *migr_map;
+
+	if (!dev->vol.migr_state)
+		return 0;
+
+	if (migr_type(dev) != MIGR_INIT)
+		return 0;
+
+	migr_map = get_imsm_map(dev, 1);
+
+	if (migr_map->map_state == IMSM_T_STATE_UNINITIALIZED)
+		return 1;
+
+	return 0;
+
+}
+
 static void update_recovery_start(struct intel_super *super,
 					struct imsm_dev *dev,
 					struct mdinfo *array)
@@ -6501,6 +6520,12 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 			super->updates_pending++;
 			break;
 		}
+		if (is_initializing(dev)) {
+			dprintf("while initialization.");
+			map->map_state = map_state;
+			super->updates_pending++;
+			break;
+		}
 	break;
 	case IMSM_T_STATE_FAILED: /* transition to failed state */
 		dprintf("failed: ");


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

* [PATCH 6/9] imsm: FIX: Mark failure for rebuild
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (4 preceding siblings ...)
  2011-12-07 12:58 ` [PATCH 5/9] imsm: FIX: Add array map state transition for failures during initialization Adam Kwolek
@ 2011-12-07 12:58 ` Adam Kwolek
  2011-12-07 12:58 ` [PATCH 7/9] imsm: FIX: Finish rebuild and initialization when missing drive is handled Adam Kwolek
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:58 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

Allow for marking failures in second map during rebuild and initialization
also (not during migration only)

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 217a196..de07f66 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6158,7 +6158,11 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
 
 	disk->status |= FAILED_DISK;
 	set_imsm_ord_tbl_ent(map, slot, idx | IMSM_ORD_REBUILD);
-	if (is_gen_migration(dev)) {
+	/* mark failures in second map if second map exists and this disk
+	 * in this slot.
+	 * This is valid for migration, initialization and rebuild
+	 */
+	if (dev->vol.migr_state) {
 		struct imsm_map *map2 = get_imsm_map(dev, 1);
 		if (slot < map2->num_members)
 			set_imsm_ord_tbl_ent(map2, slot,


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

* [PATCH 7/9] imsm: FIX: Finish rebuild and initialization when missing drive is handled
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (5 preceding siblings ...)
  2011-12-07 12:58 ` [PATCH 6/9] imsm: FIX: Mark failure for rebuild Adam Kwolek
@ 2011-12-07 12:58 ` Adam Kwolek
  2011-12-07 12:58 ` [PATCH 8/9] imsm: FIX: Check correct slots on disk failure Adam Kwolek
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:58 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

When missing device is handled for rebuild or initialization
end_migration() should be called to merge ords in case additional
degradation.

I've removed this call to end_migration() as it was called
for migration also.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index de07f66..9689fdd 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6192,6 +6192,17 @@ static void handle_missing(struct intel_super *super, struct imsm_dev *dev)
 		return;
 
 	dprintf("imsm: mark missing\n");
+	/* end process for initialization and rebuild only
+	 */
+	if (is_gen_migration(dev) == 0) {
+		__u8 map_state;
+		int failed;
+
+		failed = imsm_count_failed(super, dev, MAP_0);
+		map_state = imsm_check_degraded(super, dev, failed, MAP_0);
+
+		end_migration(dev, super, map_state);
+	}
 	for (dl = super->missing; dl; dl = dl->next)
 		mark_missing(dev, &dl->disk, dl->index);
 	super->updates_pending++;


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

* [PATCH 8/9] imsm: FIX: Check correct slots on disk failure
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (6 preceding siblings ...)
  2011-12-07 12:58 ` [PATCH 7/9] imsm: FIX: Finish rebuild and initialization when missing drive is handled Adam Kwolek
@ 2011-12-07 12:58 ` Adam Kwolek
  2011-12-07 12:58 ` [PATCH 9/9] imsm: FIX: Use defines for device map access Adam Kwolek
  2011-12-08  3:15 ` [PATCH 0/9] Array degradation during reshape and rebuild (cont.) NeilBrown
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:58 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

When changes are made to 2nd map, slot in second map should be tested
instead first one /as change will be applied to second map).

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 9689fdd..7f9c64f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4522,14 +4522,16 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
 			set_imsm_ord_tbl_ent(map, slot, df->index | IMSM_ORD_REBUILD);
 			if (is_gen_migration(dev)) {
 				struct imsm_map *map2 = get_imsm_map(dev, 1);
-				if (slot < map2->num_members) {
+				int slot2 = get_imsm_disk_slot(map2, df->index);
+				if ((slot2 < map2->num_members) &&
+				    (slot2 >= 0)) {
 					__u32 ord2 = get_imsm_ord_tbl_ent(dev,
-									  slot,
+									  slot2,
 									  1);
 					if ((unsigned)df->index ==
 							       ord_to_idx(ord2))
 						set_imsm_ord_tbl_ent(map2,
-							slot,
+							slot2,
 							df->index |
 							IMSM_ORD_REBUILD);
 				}
@@ -6164,8 +6166,11 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
 	 */
 	if (dev->vol.migr_state) {
 		struct imsm_map *map2 = get_imsm_map(dev, 1);
-		if (slot < map2->num_members)
-			set_imsm_ord_tbl_ent(map2, slot,
+		int slot2 = get_imsm_disk_slot(map2, idx);
+
+		if ((slot2 < map2->num_members) &&
+		    (slot2 >= 0))
+			set_imsm_ord_tbl_ent(map2, slot2,
 					     idx | IMSM_ORD_REBUILD);
 	}
 	if (map->failed_disk_num == 0xff)


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

* [PATCH 9/9] imsm: FIX: Use defines for device map access
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (7 preceding siblings ...)
  2011-12-07 12:58 ` [PATCH 8/9] imsm: FIX: Check correct slots on disk failure Adam Kwolek
@ 2011-12-07 12:58 ` Adam Kwolek
  2011-12-08  3:15 ` [PATCH 0/9] Array degradation during reshape and rebuild (cont.) NeilBrown
  9 siblings, 0 replies; 11+ messages in thread
From: Adam Kwolek @ 2011-12-07 12:58 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

Maps should not be accessed using "magic numbers" /0, 1,-1/.
Add proper definitions and change all map access to use them.
Change present definitions /MAP_0/MAP_1/ to values already used
in code /0, 1, -1//

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |  268 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 136 insertions(+), 132 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 7f9c64f..cea314c 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -108,8 +108,9 @@ struct imsm_disk {
 
 /* map selector for map managment
  */
-#define MAP_0		2
-#define MAP_1		4
+#define MAP_0		0
+#define MAP_1		1
+#define MAP_X		-1
 
 /* RAID map configuration infos. */
 struct imsm_map {
@@ -667,9 +668,9 @@ struct imsm_map *get_imsm_map(struct imsm_dev *dev, int second_map)
 {
 	/* A device can have 2 maps if it is in the middle of a migration.
 	 * If second_map is:
-	 *    MAP_0 or 0   - we return the first map
-	 *    MAP_1 or 1   - we return the second map if it exists, else NULL
-	 *   -1   - we return the second map if it exists, else the first
+	 *    MAP_0 - we return the first map
+	 *    MAP_1 - we return the second map if it exists, else NULL
+	 *    MAP_X - we return the second map if it exists, else the first
 	 */
 	struct imsm_map *map = &dev->vol.map[0];
 	struct imsm_map *map2 = NULL;
@@ -679,13 +680,11 @@ struct imsm_map *get_imsm_map(struct imsm_dev *dev, int second_map)
 
 	switch (second_map) {
 	case MAP_0:
-	case 0:
 		break;
 	case MAP_1:
-	case 1:
 		map = map2;
 		break;
-	case -1:
+	case MAP_X:
 		if (map2)
 			map = map2;
 		break;
@@ -702,13 +701,13 @@ struct imsm_map *get_imsm_map(struct imsm_dev *dev, int second_map)
 static size_t sizeof_imsm_dev(struct imsm_dev *dev, int migr_state)
 {
 	size_t size = sizeof(*dev) - sizeof(struct imsm_map) +
-		      sizeof_imsm_map(get_imsm_map(dev, 0));
+		      sizeof_imsm_map(get_imsm_map(dev, MAP_0));
 
 	/* migrating means an additional map */
 	if (dev->vol.migr_state)
-		size += sizeof_imsm_map(get_imsm_map(dev, 1));
+		size += sizeof_imsm_map(get_imsm_map(dev, MAP_1));
 	else if (migr_state)
-		size += sizeof_imsm_map(get_imsm_map(dev, 0));
+		size += sizeof_imsm_map(get_imsm_map(dev, MAP_0));
 
 	return size;
 }
@@ -762,9 +761,9 @@ static struct imsm_dev *get_imsm_dev(struct intel_super *super, __u8 index)
 
 /*
  * for second_map:
- *  == 0 get first map
- *  == 1 get second map
- *  == -1 than get map according to the current migr_state
+ *  == MAP_0 get first map
+ *  == MAP_1 get second map
+ *  == MAP_X than get map according to the current migr_state
  */
 static __u32 get_imsm_ord_tbl_ent(struct imsm_dev *dev,
 				  int slot,
@@ -835,7 +834,7 @@ static int count_memberships(struct dl *dl, struct intel_super *super)
 
 	for (i = 0; i < super->anchor->num_raid_devs; i++) {
 		struct imsm_dev *dev = get_imsm_dev(super, i);
-		struct imsm_map *map = get_imsm_map(dev, 0);
+		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 
 		if (get_imsm_disk_slot(map, dl->index) >= 0)
 			memberships++;
@@ -870,7 +869,7 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl)
 
 	for (i = 0; i < super->anchor->num_raid_devs; i++) {
 		struct imsm_dev *dev = get_imsm_dev(super, i);
-		struct imsm_map *map = get_imsm_map(dev, 0);
+		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 
 		if (get_imsm_disk_slot(map, dl->index) >= 0) {
 			e->start = __le32_to_cpu(map->pba_of_lba0);
@@ -1043,8 +1042,8 @@ static void print_imsm_dev(struct intel_super *super,
 {
 	__u64 sz;
 	int slot, i;
-	struct imsm_map *map = get_imsm_map(dev, 0);
-	struct imsm_map *map2 = get_imsm_map(dev, 1);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
+	struct imsm_map *map2 = get_imsm_map(dev, MAP_1);
 	__u32 ord;
 
 	printf("\n");
@@ -1060,14 +1059,14 @@ static void print_imsm_dev(struct intel_super *super,
 	printf("\n");
 	printf("          Slots : [");
 	for (i = 0; i < map->num_members; i++) {
-		ord = get_imsm_ord_tbl_ent(dev, i, 0);
+		ord = get_imsm_ord_tbl_ent(dev, i, MAP_0);
 		printf("%s", ord & IMSM_ORD_REBUILD ? "_" : "U");
 	}
 	printf("]");
 	if (map2) {
 		printf(" <-- [");
 		for (i = 0; i < map2->num_members; i++) {
-			ord = get_imsm_ord_tbl_ent(dev, i, 1);
+			ord = get_imsm_ord_tbl_ent(dev, i, MAP_1);
 			printf("%s", ord & IMSM_ORD_REBUILD ? "_" : "U");
 		}
 		printf("]");
@@ -1081,7 +1080,7 @@ static void print_imsm_dev(struct intel_super *super,
 	printf("\n");
 	slot = get_imsm_disk_slot(map, disk_idx);
 	if (slot >= 0) {
-		ord = get_imsm_ord_tbl_ent(dev, slot, -1);
+		ord = get_imsm_ord_tbl_ent(dev, slot, MAP_X);
 		printf("      This Slot : %d%s\n", slot,
 		       ord & IMSM_ORD_REBUILD ? " (out-of-sync)" : "");
 	} else
@@ -1125,7 +1124,7 @@ static void print_imsm_dev(struct intel_super *super,
 		printf("idle\n");
 	printf("      Map State : %s", map_state_str[map->map_state]);
 	if (dev->vol.migr_state) {
-		struct imsm_map *map = get_imsm_map(dev, 1);
+		struct imsm_map *map = get_imsm_map(dev, MAP_1);
 
 		printf(" <-- %s", map_state_str[map->map_state]);
 		printf("\n     Checkpoint : %u ",
@@ -1860,7 +1859,7 @@ get_imsm_numerical_version(struct imsm_super *mpb, int *m, int *p)
 static __u32 migr_strip_blocks_resync(struct imsm_dev *dev)
 {
 	/* migr_strip_size when repairing or initializing parity */
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	__u32 chunk = __le32_to_cpu(map->blocks_per_strip);
 
 	switch (get_imsm_raid_level(map)) {
@@ -1878,7 +1877,7 @@ static __u32 migr_strip_blocks_rebuild(struct imsm_dev *dev)
 	 * this is different than migr_strip_size_resync(), but it's good
 	 * to be compatible
 	 */
-	struct imsm_map *map = get_imsm_map(dev, 1);
+	struct imsm_map *map = get_imsm_map(dev, MAP_1);
 	__u32 chunk = __le32_to_cpu(map->blocks_per_strip);
 
 	switch (get_imsm_raid_level(map)) {
@@ -1897,8 +1896,8 @@ static __u32 migr_strip_blocks_rebuild(struct imsm_dev *dev)
 
 static __u32 num_stripes_per_unit_resync(struct imsm_dev *dev)
 {
-	struct imsm_map *lo = get_imsm_map(dev, 0);
-	struct imsm_map *hi = get_imsm_map(dev, 1);
+	struct imsm_map *lo = get_imsm_map(dev, MAP_0);
+	struct imsm_map *hi = get_imsm_map(dev, MAP_1);
 	__u32 lo_chunk = __le32_to_cpu(lo->blocks_per_strip);
 	__u32 hi_chunk = __le32_to_cpu(hi->blocks_per_strip);
 
@@ -1907,11 +1906,11 @@ static __u32 num_stripes_per_unit_resync(struct imsm_dev *dev)
 
 static __u32 num_stripes_per_unit_rebuild(struct imsm_dev *dev)
 {
-	struct imsm_map *lo = get_imsm_map(dev, 0);
+	struct imsm_map *lo = get_imsm_map(dev, MAP_0);
 	int level = get_imsm_raid_level(lo);
 
 	if (level == 1 || level == 10) {
-		struct imsm_map *hi = get_imsm_map(dev, 1);
+		struct imsm_map *hi = get_imsm_map(dev, MAP_1);
 
 		return hi->num_domains;
 	} else
@@ -1940,7 +1939,7 @@ static __u8 imsm_num_data_members(struct imsm_dev *dev, int second_map)
 
 static __u32 parity_segment_depth(struct imsm_dev *dev)
 {
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	__u32 chunk =  __le32_to_cpu(map->blocks_per_strip);
 
 	switch(get_imsm_raid_level(map)) {
@@ -1956,7 +1955,7 @@ static __u32 parity_segment_depth(struct imsm_dev *dev)
 
 static __u32 map_migr_block(struct imsm_dev *dev, __u32 block)
 {
-	struct imsm_map *map = get_imsm_map(dev, 1);
+	struct imsm_map *map = get_imsm_map(dev, MAP_1);
 	__u32 chunk = __le32_to_cpu(map->blocks_per_strip);
 	__u32 strip = block / chunk;
 
@@ -1995,7 +1994,7 @@ static __u64 blocks_per_migr_unit(struct intel_super *super,
 	case MIGR_VERIFY:
 	case MIGR_REPAIR:
 	case MIGR_INIT: {
-		struct imsm_map *map = get_imsm_map(dev, 0);
+		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 		__u32 stripes_per_unit;
 		__u32 blocks_per_unit;
 		__u32 parity_depth;
@@ -2011,7 +2010,7 @@ static __u64 blocks_per_migr_unit(struct intel_super *super,
 		 */
 		stripes_per_unit = num_stripes_per_unit_resync(dev);
 		migr_chunk = migr_strip_blocks_resync(dev);
-		disks = imsm_num_data_members(dev, 0);
+		disks = imsm_num_data_members(dev, MAP_0);
 		blocks_per_unit = stripes_per_unit * migr_chunk * disks;
 		stripe = __le16_to_cpu(map->blocks_per_strip) * disks;
 		segment = blocks_per_unit / stripe;
@@ -2284,8 +2283,8 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
 	struct intel_super *super = st->sb;
 	struct migr_record *migr_rec = super->migr_rec;
 	struct imsm_dev *dev = get_imsm_dev(super, super->current_vol);
-	struct imsm_map *map = get_imsm_map(dev, 0);
-	struct imsm_map *prev_map = get_imsm_map(dev, 1);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
+	struct imsm_map *prev_map = get_imsm_map(dev, MAP_1);
 	struct imsm_map *map_to_analyse = map;
 	struct dl *dl;
 	char *devname;
@@ -2430,7 +2429,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
 				(unsigned long long)blocks_per_unit,
 				info->reshape_progress);
 
-			used_disks = imsm_num_data_members(dev, 1);
+			used_disks = imsm_num_data_members(dev, MAP_1);
 			if (used_disks > 0) {
 				array_blocks = map->blocks_per_member *
 					used_disks;
@@ -2475,7 +2474,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
 			dmap[i] = 0;
 			if (i < info->array.raid_disks) {
 				struct imsm_disk *dsk;
-				j = get_imsm_disk_idx(dev, i, -1);
+				j = get_imsm_disk_idx(dev, i, MAP_X);
 				dsk = get_imsm_disk(super, j);
 				if (dsk && (dsk->status & CONFIGURED_DISK))
 					dmap[i] = 1;
@@ -2498,8 +2497,7 @@ static void manage_second_map(struct intel_super *super, struct imsm_dev *dev)
 		struct imsm_map *map2 = get_imsm_map(dev, MAP_1);
 
 		failed = imsm_count_failed(super, dev, MAP_1);
-		map_state = imsm_check_degraded(super, dev, failed,
-						MAP_1);
+		map_state = imsm_check_degraded(super, dev, failed, MAP_1);
 		if (map2->map_state != map_state) {
 			map2->map_state = map_state;
 			super->updates_pending++;
@@ -2568,13 +2566,13 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
 
 		failed = imsm_count_failed(super, dev, MAP_0);
 		state = imsm_check_degraded(super, dev, failed, MAP_0);
-		map = get_imsm_map(dev, 0);
+		map = get_imsm_map(dev, MAP_0);
 
 		/* any newly missing disks?
 		 * (catches single-degraded vs double-degraded)
 		 */
 		for (j = 0; j < map->num_members; j++) {
-			__u32 ord = get_imsm_ord_tbl_ent(dev, j, 0);
+			__u32 ord = get_imsm_ord_tbl_ent(dev, j, MAP_0);
 			__u32 idx = ord_to_idx(ord);
 
 			if (!(ord & IMSM_ORD_REBUILD) &&
@@ -3101,12 +3099,12 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super,
 		    __u8 to_state, int migr_type)
 {
 	struct imsm_map *dest;
-	struct imsm_map *src = get_imsm_map(dev, 0);
+	struct imsm_map *src = get_imsm_map(dev, MAP_0);
 
 	dev->vol.migr_state = 1;
 	set_migr_type(dev, migr_type);
 	dev->vol.curr_migr_unit = 0;
-	dest = get_imsm_map(dev, 1);
+	dest = get_imsm_map(dev, MAP_1);
 
 	/* duplicate and then set the target end state in map[0] */
 	memcpy(dest, src, sizeof_imsm_map(src));
@@ -3131,8 +3129,9 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super,
 static void end_migration(struct imsm_dev *dev, struct intel_super *super,
 			  __u8 map_state)
 {
-	struct imsm_map *map = get_imsm_map(dev, 0);
-	struct imsm_map *prev = get_imsm_map(dev, dev->vol.migr_state);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
+	struct imsm_map *prev = get_imsm_map(dev, dev->vol.migr_state == 0 ?
+						    MAP_0 : MAP_1);
 	int i, j;
 
 	/* merge any IMSM_ORD_REBUILD bits that were not successfully
@@ -3264,8 +3263,8 @@ int check_mpb_migr_compatibility(struct intel_super *super)
 		    dev_iter->vol.migr_state == 1 &&
 		    dev_iter->vol.migr_type == MIGR_GEN_MIGR) {
 			/* This device is migrating */
-			map0 = get_imsm_map(dev_iter, 0);
-			map1 = get_imsm_map(dev_iter, 1);
+			map0 = get_imsm_map(dev_iter, MAP_0);
+			map1 = get_imsm_map(dev_iter, MAP_1);
 			if (map0->pba_of_lba0 != map1->pba_of_lba0)
 				/* migration optimization area was used */
 				return -1;
@@ -4152,7 +4151,7 @@ static void imsm_update_version_info(struct intel_super *super)
 
 	for (i = 0; i < mpb->num_raid_devs; i++) {
 		dev = get_imsm_dev(super, i);
-		map = get_imsm_map(dev, 0);
+		map = get_imsm_map(dev, MAP_0);
 		if (__le32_to_cpu(dev->size_high) > 0)
 			mpb->attributes |= MPB_ATTRIB_2TB;
 
@@ -4332,7 +4331,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
 	set_migr_type(dev, MIGR_INIT);
 	vol->dirty = !info->state;
 	vol->curr_migr_unit = 0;
-	map = get_imsm_map(dev, 0);
+	map = get_imsm_map(dev, MAP_0);
 	map->pba_of_lba0 = __cpu_to_le32(super->create_offset);
 	map->blocks_per_member = __cpu_to_le32(info_to_blocks_per_member(info));
 	map->blocks_per_strip = __cpu_to_le16(info_to_blocks_per_strip(info));
@@ -4456,7 +4455,7 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
 	int slot;
 
 	dev = get_imsm_dev(super, super->current_vol);
-	map = get_imsm_map(dev, 0);
+	map = get_imsm_map(dev, MAP_0);
 
 	if (! (dk->state & (1<<MD_DISK_SYNC))) {
 		fprintf(stderr, Name ": %s: Cannot add spare devices to IMSM volume\n",
@@ -4491,7 +4490,7 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
 	/* Check the device has not already been added */
 	slot = get_imsm_disk_slot(map, dl->index);
 	if (slot >= 0 &&
-	    (get_imsm_ord_tbl_ent(dev, slot, -1) & IMSM_ORD_REBUILD) == 0) {
+	    (get_imsm_ord_tbl_ent(dev, slot, MAP_X) & IMSM_ORD_REBUILD) == 0) {
 		fprintf(stderr, Name ": %s has been included in this array twice\n",
 			devname);
 		return 1;
@@ -4515,19 +4514,20 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
 	/* refresh unset/failed slots to point to valid 'missing' entries */
 	for (df = super->missing; df; df = df->next)
 		for (slot = 0; slot < mpb->num_disks; slot++) {
-			__u32 ord = get_imsm_ord_tbl_ent(dev, slot, -1);
+			__u32 ord = get_imsm_ord_tbl_ent(dev, slot, MAP_X);
 
 			if ((ord & IMSM_ORD_REBUILD) == 0)
 				continue;
 			set_imsm_ord_tbl_ent(map, slot, df->index | IMSM_ORD_REBUILD);
 			if (is_gen_migration(dev)) {
-				struct imsm_map *map2 = get_imsm_map(dev, 1);
+				struct imsm_map *map2 = get_imsm_map(dev,
+								     MAP_1);
 				int slot2 = get_imsm_disk_slot(map2, df->index);
 				if ((slot2 < map2->num_members) &&
 				    (slot2 >= 0)) {
 					__u32 ord2 = get_imsm_ord_tbl_ent(dev,
-									  slot2,
-									  1);
+									 slot2,
+									 MAP_1);
 					if ((unsigned)df->index ==
 							       ord_to_idx(ord2))
 						set_imsm_ord_tbl_ent(map2,
@@ -4846,7 +4846,7 @@ static int create_array(struct supertype *st, int dev_idx)
 	struct imsm_update_create_array *u;
 	struct intel_super *super = st->sb;
 	struct imsm_dev *dev = get_imsm_dev(super, dev_idx);
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	struct disk_info *inf;
 	struct imsm_disk *disk;
 	int i;
@@ -4865,7 +4865,7 @@ static int create_array(struct supertype *st, int dev_idx)
 	imsm_copy_dev(&u->dev, dev);
 	inf = get_disk_info(u);
 	for (i = 0; i < map->num_members; i++) {
-		int idx = get_imsm_disk_idx(dev, i, -1);
+		int idx = get_imsm_disk_idx(dev, i, MAP_X);
 
 		disk = get_imsm_disk(super, idx);
 		serialcpy(inf[i].serial, disk->serial);
@@ -5712,7 +5712,7 @@ static int is_rebuilding(struct imsm_dev *dev)
 	if (migr_type(dev) != MIGR_REBUILD)
 		return 0;
 
-	migr_map = get_imsm_map(dev, 1);
+	migr_map = get_imsm_map(dev, MAP_1);
 
 	if (migr_map->map_state == IMSM_T_STATE_DEGRADED)
 		return 1;
@@ -5730,7 +5730,7 @@ static int is_initializing(struct imsm_dev *dev)
 	if (migr_type(dev) != MIGR_INIT)
 		return 0;
 
-	migr_map = get_imsm_map(dev, 1);
+	migr_map = get_imsm_map(dev, MAP_1);
 
 	if (migr_map->map_state == IMSM_T_STATE_UNINITIALIZED)
 		return 1;
@@ -5828,8 +5828,8 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
 			continue;
 
 		dev = get_imsm_dev(super, i);
-		map = get_imsm_map(dev, 0);
-		map2 = get_imsm_map(dev, 1);
+		map = get_imsm_map(dev, MAP_0);
+		map2 = get_imsm_map(dev, MAP_1);
 
 		/* do not publish arrays that are in the middle of an
 		 * unsupported migration
@@ -5888,8 +5888,8 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
 			__u32 ord;
 
 			skip = 0;
-			idx = get_imsm_disk_idx(dev, slot, 0);
-			ord = get_imsm_ord_tbl_ent(dev, slot, -1);
+			idx = get_imsm_disk_idx(dev, slot, MAP_0);
+			ord = get_imsm_ord_tbl_ent(dev, slot, MAP_X);
 			for (d = super->disks; d ; d = d->next)
 				if (d->index == idx)
 					break;
@@ -6004,7 +6004,7 @@ static __u8 imsm_check_degraded(struct intel_super *super, struct imsm_dev *dev,
 		int insync = insync;
 
 		for (i = 0; i < map->num_members; i++) {
-			__u32 ord = get_imsm_ord_tbl_ent(dev, i, -1);
+			__u32 ord = get_imsm_ord_tbl_ent(dev, i, MAP_X);
 			int idx = ord_to_idx(ord);
 			struct imsm_disk *disk;
 
@@ -6065,8 +6065,11 @@ static int imsm_count_failed(struct intel_super *super, struct imsm_dev *dev,
 
 	for (i = 0; i < map_for_loop->num_members; i++) {
 		idx_1 = -255;
+		/* when MAP_X is passed both maps failures are counted
+		 */
 		if (prev &&
-		    (look_in_map & MAP_1) && (i < prev->num_members)) {
+		    ((look_in_map == MAP_1) || (look_in_map == MAP_X)) &&
+		    (i < prev->num_members)) {
 			ord = __le32_to_cpu(prev->disk_ord_tbl[i]);
 			idx_1 = ord_to_idx(ord);
 
@@ -6074,7 +6077,8 @@ static int imsm_count_failed(struct intel_super *super, struct imsm_dev *dev,
 			if (!disk || is_failed(disk) || ord & IMSM_ORD_REBUILD)
 				failed++;
 		}
-		if ((look_in_map & MAP_0) && (i < map->num_members)) {
+		if (((look_in_map == MAP_0) || (look_in_map == MAP_X)) &&
+		    (i < map->num_members)) {
 			ord = __le32_to_cpu(map->disk_ord_tbl[i]);
 			idx = ord_to_idx(ord);
 
@@ -6122,7 +6126,7 @@ static int is_resyncing(struct imsm_dev *dev)
 	if (migr_type(dev) == MIGR_GEN_MIGR)
 		return 0;
 
-	migr_map = get_imsm_map(dev, 1);
+	migr_map = get_imsm_map(dev, MAP_1);
 
 	if ((migr_map->map_state == IMSM_T_STATE_NORMAL) &&
 	    (dev->vol.migr_type != MIGR_GEN_MIGR))
@@ -6141,7 +6145,7 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
 	unsigned int len, shift = 0;
 
 	/* new failures are always set in map[0] */
-	map = get_imsm_map(dev, 0);
+	map = get_imsm_map(dev, MAP_0);
 
 	slot = get_imsm_disk_slot(map, idx);
 	if (slot < 0)
@@ -6165,7 +6169,7 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
 	 * This is valid for migration, initialization and rebuild
 	 */
 	if (dev->vol.migr_state) {
-		struct imsm_map *map2 = get_imsm_map(dev, 1);
+		struct imsm_map *map2 = get_imsm_map(dev, MAP_1);
 		int slot2 = get_imsm_disk_slot(map2, idx);
 
 		if ((slot2 < map2->num_members) &&
@@ -6215,7 +6219,7 @@ static void handle_missing(struct intel_super *super, struct imsm_dev *dev)
 
 static unsigned long long imsm_set_array_size(struct imsm_dev *dev)
 {
-	int used_disks = imsm_num_data_members(dev, 0);
+	int used_disks = imsm_num_data_members(dev, MAP_0);
 	unsigned long long array_blocks;
 	struct imsm_map *map;
 
@@ -6232,7 +6236,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev)
 
 	/* set array size in metadata
 	 */
-	map = get_imsm_map(dev, 0);
+	map = get_imsm_map(dev, MAP_0);
 	array_blocks = map->blocks_per_member * used_disks;
 
 	/* round array size down to closest MB
@@ -6260,7 +6264,7 @@ static void imsm_progress_container_reshape(struct intel_super *super)
 
 	for (i = 0; i < mpb->num_raid_devs; i++) {
 		struct imsm_dev *dev = get_imsm_dev(super, i);
-		struct imsm_map *map = get_imsm_map(dev, 0);
+		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 		struct imsm_map *map2;
 		int prev_num_members;
 
@@ -6285,7 +6289,7 @@ static void imsm_progress_container_reshape(struct intel_super *super)
 		for (i = prev_num_members;
 		     i < map->num_members; i++)
 			set_imsm_ord_tbl_ent(map, i, i);
-		map2 = get_imsm_map(dev, 1);
+		map2 = get_imsm_map(dev, MAP_1);
 		/* Copy the current map */
 		memcpy(map2, map, copy_map_size);
 		map2->num_members = prev_num_members;
@@ -6305,7 +6309,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
 	int inst = a->info.container_member;
 	struct intel_super *super = a->container->sb;
 	struct imsm_dev *dev = get_imsm_dev(super, inst);
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	int failed = imsm_count_failed(super, dev, MAP_0);
 	__u8 map_state = imsm_check_degraded(super, dev, failed, MAP_0);
 	__u32 blocks_per_unit;
@@ -6329,12 +6333,14 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
 				 * user action is required to recover process
 				 */
 				if (0) {
-				struct imsm_map *map2 = get_imsm_map(dev, 1);
-				dev->vol.migr_state = 0;
-				set_migr_type(dev, 0);
-				dev->vol.curr_migr_unit = 0;
-				memcpy(map, map2, sizeof_imsm_map(map2));
-				super->updates_pending++;
+					struct imsm_map *map2 =
+						get_imsm_map(dev, MAP_1);
+					dev->vol.migr_state = 0;
+					set_migr_type(dev, 0);
+					dev->vol.curr_migr_unit = 0;
+					memcpy(map, map2,
+					       sizeof_imsm_map(map2));
+					super->updates_pending++;
 				}
 			}
 			if (a->last_checkpoint >= a->info.component_size) {
@@ -6342,7 +6348,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
 				int used_disks;
 				struct mdinfo *mdi;
 
-				used_disks = imsm_num_data_members(dev, 0);
+				used_disks = imsm_num_data_members(dev, MAP_0);
 				if (used_disks > 0) {
 					array_blocks =
 						map->blocks_per_member *
@@ -6449,7 +6455,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 	int inst = a->info.container_member;
 	struct intel_super *super = a->container->sb;
 	struct imsm_dev *dev = get_imsm_dev(super, inst);
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	struct imsm_disk *disk;
 	int failed;
 	__u32 ord;
@@ -6464,7 +6470,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 
 	dprintf("imsm: set_disk %d:%x\n", n, state);
 
-	ord = get_imsm_ord_tbl_ent(dev, n, 0);
+	ord = get_imsm_ord_tbl_ent(dev, n, MAP_0);
 	disk = get_imsm_disk(super, ord_to_idx(ord));
 
 	/* check for new failures */
@@ -6475,7 +6481,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 
 	/* check if in_sync */
 	if (state & DS_INSYNC && ord & IMSM_ORD_REBUILD && is_rebuilding(dev)) {
-		struct imsm_map *migr_map = get_imsm_map(dev, 1);
+		struct imsm_map *migr_map = get_imsm_map(dev, MAP_1);
 
 		set_imsm_ord_tbl_ent(migr_map, n, ord_to_idx(ord));
 		super->updates_pending++;
@@ -6492,7 +6498,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 		if (is_rebuilding(dev)) {
 			dprintf("while rebuilding");
 			end_migration(dev, super, map_state);
-			map = get_imsm_map(dev, 0);
+			map = get_imsm_map(dev, MAP_0);
 			map->failed_disk_num = ~0;
 			super->updates_pending++;
 			a->last_checkpoint = 0;
@@ -6504,7 +6510,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
 				end_migration(dev, super, map_state);
 			else
 				map->map_state = map_state;
-			map = get_imsm_map(dev, 0);
+			map = get_imsm_map(dev, MAP_0);
 			map->failed_disk_num = ~0;
 			super->updates_pending++;
 			break;
@@ -6618,7 +6624,7 @@ static void imsm_sync_metadata(struct supertype *container)
 static struct dl *imsm_readd(struct intel_super *super, int idx, struct active_array *a)
 {
 	struct imsm_dev *dev = get_imsm_dev(super, a->info.container_member);
-	int i = get_imsm_disk_idx(dev, idx, -1);
+	int i = get_imsm_disk_idx(dev, idx, MAP_X);
 	struct dl *dl;
 
 	for (dl = super->disks; dl; dl = dl->next)
@@ -6639,7 +6645,7 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot,
 				 struct mdinfo *additional_test_list)
 {
 	struct imsm_dev *dev = get_imsm_dev(super, a->info.container_member);
-	int idx = get_imsm_disk_idx(dev, slot, -1);
+	int idx = get_imsm_disk_idx(dev, slot, MAP_X);
 	struct imsm_super *mpb = super->anchor;
 	struct imsm_map *map;
 	unsigned long long pos;
@@ -6701,7 +6707,7 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot,
 		}
 		for (i = 0; i < mpb->num_raid_devs; i++) {
 			dev = get_imsm_dev(super, i);
-			map = get_imsm_map(dev, 0);
+			map = get_imsm_map(dev, MAP_0);
 
 			/* check if this disk is already a member of
 			 * this array
@@ -6757,10 +6763,9 @@ static int imsm_rebuild_allowed(struct supertype *cont, int dev_idx, int failed)
 
 	dev2 = get_imsm_dev(cont->sb, dev_idx);
 	if (dev2) {
-		state = imsm_check_degraded(cont->sb, dev2, failed,
-					    MAP_0);
+		state = imsm_check_degraded(cont->sb, dev2, failed, MAP_0);
 		if (state == IMSM_T_STATE_FAILED) {
-			map = get_imsm_map(dev2, 0);
+			map = get_imsm_map(dev2, MAP_0);
 			if (!map)
 				return 1;
 			for (slot = 0; slot < map->num_members; slot++) {
@@ -6768,7 +6773,7 @@ static int imsm_rebuild_allowed(struct supertype *cont, int dev_idx, int failed)
 				 * Check if failed disks are deleted from intel
 				 * disk list or are marked to be deleted
 				 */
-				idx = get_imsm_disk_idx(dev2, slot, -1);
+				idx = get_imsm_disk_idx(dev2, slot, MAP_X);
 				idisk = get_imsm_dl_disk(cont->sb, idx);
 				/*
 				 * Do not rebuild the array if failed disks
@@ -6802,7 +6807,7 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
 	struct intel_super *super = a->container->sb;
 	int inst = a->info.container_member;
 	struct imsm_dev *dev = get_imsm_dev(super, inst);
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	int failed = a->info.array.raid_disks;
 	struct mdinfo *rv = NULL;
 	struct mdinfo *d;
@@ -6975,15 +6980,15 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
 static int disks_overlap(struct intel_super *super, int idx, struct imsm_update_create_array *u)
 {
 	struct imsm_dev *dev = get_imsm_dev(super, idx);
-	struct imsm_map *map = get_imsm_map(dev, 0);
-	struct imsm_map *new_map = get_imsm_map(&u->dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
+	struct imsm_map *new_map = get_imsm_map(&u->dev, MAP_0);
 	struct disk_info *inf = get_disk_info(u);
 	struct imsm_disk *disk;
 	int i;
 	int j;
 
 	for (i = 0; i < map->num_members; i++) {
-		disk = get_imsm_disk(super, get_imsm_disk_idx(dev, i, -1));
+		disk = get_imsm_disk(super, get_imsm_disk_idx(dev, i, MAP_X));
 		for (j = 0; j < new_map->num_members; j++)
 			if (serialcmp(disk->serial, inf[j].serial) == 0)
 				return 1;
@@ -7096,7 +7101,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
 			struct imsm_map *map;
 			struct imsm_dev *new_dev =
 				(struct imsm_dev *)*space_list;
-			struct imsm_map *migr_map = get_imsm_map(dev, 1);
+			struct imsm_map *migr_map = get_imsm_map(dev, MAP_1);
 			int to_state;
 			struct dl *new_disk;
 
@@ -7104,7 +7109,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
 				return ret_val;
 			*space_list = **space_list;
 			memcpy(new_dev, dev, sizeof_imsm_dev(dev, 0));
-			map = get_imsm_map(new_dev, 0);
+			map = get_imsm_map(new_dev, MAP_0);
 			if (migr_map) {
 				dprintf("imsm: Error: migration in progress");
 				return ret_val;
@@ -7124,7 +7129,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
 			migrate(new_dev, super, to_state, MIGR_GEN_MIGR);
 			if (u->new_level > -1)
 				map->raid_level = u->new_level;
-			migr_map = get_imsm_map(new_dev, 1);
+			migr_map = get_imsm_map(new_dev, MAP_1);
 			if ((u->new_level == 5) &&
 			    (migr_map->raid_level == 0)) {
 				int ord = map->num_members - 1;
@@ -7199,7 +7204,7 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 {
 	struct imsm_super *mpb = super->anchor;
 	struct imsm_dev *dev = get_imsm_dev(super, u->array);
-	struct imsm_map *map = get_imsm_map(dev, 0);
+	struct imsm_map *map = get_imsm_map(dev, MAP_0);
 	struct imsm_map *migr_map;
 	struct active_array *a;
 	struct imsm_disk *disk;
@@ -7212,7 +7217,7 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 	int second_map_created = 0;
 
 	for (; u; u = u->next) {
-		victim = get_imsm_disk_idx(dev, u->slot, -1);
+		victim = get_imsm_disk_idx(dev, u->slot, MAP_X);
 
 		if (victim < 0)
 			return 0;
@@ -7236,7 +7241,7 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 			if (i == u->slot)
 				continue;
 			disk = get_imsm_disk(super,
-					     get_imsm_disk_idx(dev, i, -1));
+					     get_imsm_disk_idx(dev, i, MAP_X));
 			if (!disk || is_failed(disk))
 				failed++;
 		}
@@ -7251,15 +7256,14 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 		disk->status &= ~SPARE_DISK;
 
 		/* mark rebuild */
-		to_state = imsm_check_degraded(super, dev, failed,
-					       MAP_0);
+		to_state = imsm_check_degraded(super, dev, failed, MAP_0);
 		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);
+		migr_map = get_imsm_map(dev, MAP_1);
 		set_imsm_ord_tbl_ent(map, u->slot, dl->index);
 		set_imsm_ord_tbl_ent(migr_map, u->slot,
 				     dl->index | IMSM_ORD_REBUILD);
@@ -7277,7 +7281,7 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u,
 		found = 0;
 		for (a = active_array; a ; a = a->next) {
 			dev = get_imsm_dev(super, a->info.container_member);
-			map = get_imsm_map(dev, 0);
+			map = get_imsm_map(dev, MAP_0);
 
 			if (get_imsm_disk_slot(map, victim) >= 0)
 				found++;
@@ -7369,8 +7373,8 @@ static int apply_reshape_container_disks_update(struct imsm_update_reshape *u,
 		newdev = (void*)sp;
 		/* Copy the dev, but not (all of) the map */
 		memcpy(newdev, id->dev, sizeof(*newdev));
-		oldmap = get_imsm_map(id->dev, 0);
-		newmap = get_imsm_map(newdev, 0);
+		oldmap = get_imsm_map(id->dev, MAP_0);
+		newmap = get_imsm_map(newdev, MAP_0);
 		/* Copy the current map */
 		memcpy(newmap, oldmap, sizeof_imsm_map(oldmap));
 		/* update one device only
@@ -7390,7 +7394,7 @@ static int apply_reshape_container_disks_update(struct imsm_update_reshape *u,
 			}
 			/* New map is correct, now need to save old map
 			 */
-			newmap = get_imsm_map(newdev, 1);
+			newmap = get_imsm_map(newdev, MAP_1);
 			memcpy(newmap, oldmap, sizeof_imsm_map(oldmap));
 
 			imsm_set_array_size(newdev);
@@ -7433,7 +7437,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u,
 	if (dev == NULL)
 		return 0;
 
-	map = get_imsm_map(dev, 0);
+	map = get_imsm_map(dev, MAP_0);
 
 	if (u->direction == R10_TO_R0) {
 		/* Number of failed disks must be half of initial disk number */
@@ -7497,7 +7501,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u,
 		dev_new = (void *)space;
 		memcpy(dev_new, dev, sizeof(*dev));
 		/* update new map */
-		map = get_imsm_map(dev_new, 0);
+		map = get_imsm_map(dev_new, MAP_0);
 		map->num_members = map->num_members * 2;
 		map->map_state = IMSM_T_STATE_DEGRADED;
 		map->num_domains = 2;
@@ -7641,7 +7645,7 @@ static void imsm_process_update(struct supertype *st,
 			goto create_error;
 		}
 
-		new_map = get_imsm_map(&u->dev, 0);
+		new_map = get_imsm_map(&u->dev, MAP_0);
 		new_start = __le32_to_cpu(new_map->pba_of_lba0);
 		new_end = new_start + __le32_to_cpu(new_map->blocks_per_member);
 		inf = get_disk_info(u);
@@ -7652,7 +7656,7 @@ static void imsm_process_update(struct supertype *st,
 		 */
 		for (i = 0; i < mpb->num_raid_devs; i++) {
 			dev = get_imsm_dev(super, i);
-			map = get_imsm_map(dev, 0);
+			map = get_imsm_map(dev, MAP_0);
 			start = __le32_to_cpu(map->pba_of_lba0);
 			end = start + __le32_to_cpu(map->blocks_per_member);
 			if ((new_start >= start && new_start <= end) ||
@@ -7833,7 +7837,7 @@ static void imsm_prepare_update(struct supertype *st,
 		if (u->direction == R0_TO_R10) {
 			void **tail = (void **)&update->space_list;
 			struct imsm_dev *dev = get_imsm_dev(super, u->subarray);
-			struct imsm_map *map = get_imsm_map(dev, 0);
+			struct imsm_map *map = get_imsm_map(dev, MAP_0);
 			int num_members = map->num_members;
 			void *space;
 			int size, i;
@@ -7965,7 +7969,7 @@ static void imsm_prepare_update(struct supertype *st,
 				struct imsm_map *map;
 
 				dev = get_imsm_dev(super, u->subdev);
-				map = get_imsm_map(dev, 0);
+				map = get_imsm_map(dev, MAP_0);
 				current_level = map->raid_level;
 				break;
 			}
@@ -7999,7 +8003,7 @@ static void imsm_prepare_update(struct supertype *st,
 		struct imsm_update_create_array *u = (void *) update->buf;
 		struct intel_dev *dv;
 		struct imsm_dev *dev = &u->dev;
-		struct imsm_map *map = get_imsm_map(dev, 0);
+		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 		struct dl *dl;
 		struct disk_info *inf;
 		int i;
@@ -8084,20 +8088,20 @@ static void imsm_delete(struct intel_super *super, struct dl **dlp, unsigned ind
 
 	for (i = 0; i < mpb->num_raid_devs; i++) {
 		dev = get_imsm_dev(super, i);
-		map = get_imsm_map(dev, 0);
+		map = get_imsm_map(dev, MAP_0);
 		num_members = map->num_members;
 		for (j = 0; j < num_members; j++) {
 			/* update ord entries being careful not to propagate
 			 * ord-flags to the first map
 			 */
-			ord = get_imsm_ord_tbl_ent(dev, j, -1);
+			ord = get_imsm_ord_tbl_ent(dev, j, MAP_X);
 
 			if (ord_to_idx(ord) <= index)
 				continue;
 
-			map = get_imsm_map(dev, 0);
+			map = get_imsm_map(dev, MAP_0);
 			set_imsm_ord_tbl_ent(map, j, ord_to_idx(ord - 1));
-			map = get_imsm_map(dev, 1);
+			map = get_imsm_map(dev, MAP_1);
 			if (map)
 				set_imsm_ord_tbl_ent(map, j, ord - 1);
 		}
@@ -8143,7 +8147,7 @@ static int imsm_get_allowed_degradation(int level, int raid_disks,
 		/* check map if all disks pairs not failed
 		 * in both maps
 		 */
-		map = get_imsm_map(dev, 0);
+		map = get_imsm_map(dev, MAP_0);
 		for (i = 0; i < ret_val; i++) {
 			int degradation = 0;
 			if (get_imsm_disk(super, i) == NULL)
@@ -8153,7 +8157,7 @@ static int imsm_get_allowed_degradation(int level, int raid_disks,
 			if (degradation == 2)
 				return 0;
 		}
-		map = get_imsm_map(dev, 1);
+		map = get_imsm_map(dev, MAP_1);
 		/* if there is no second map
 		 * result can be returned
 		 */
@@ -8262,8 +8266,8 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev,
 	struct mdinfo *sd;
 	char nm[30];
 	int fd;
-	struct imsm_map *map_dest = get_imsm_map(dev, 0);
-	struct imsm_map *map_src = get_imsm_map(dev, 1);
+	struct imsm_map *map_dest = get_imsm_map(dev, MAP_0);
+	struct imsm_map *map_src = get_imsm_map(dev, MAP_1);
 	unsigned long long num_migr_units;
 	unsigned long long array_blocks;
 
@@ -8276,7 +8280,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev,
 	migr_rec->dest_depth_per_unit = GEN_MIGR_AREA_SIZE /
 		max(map_dest->blocks_per_strip, map_src->blocks_per_strip);
 	migr_rec->dest_depth_per_unit *= map_dest->blocks_per_strip;
-	new_data_disks = imsm_num_data_members(dev, 0);
+	new_data_disks = imsm_num_data_members(dev, MAP_0);
 	migr_rec->blocks_per_unit =
 		__cpu_to_le32(migr_rec->dest_depth_per_unit * new_data_disks);
 	migr_rec->dest_depth_per_unit =
@@ -8340,12 +8344,12 @@ int save_backup_imsm(struct supertype *st,
 	unsigned long long *target_offsets = NULL;
 	int *targets = NULL;
 	int i;
-	struct imsm_map *map_dest = get_imsm_map(dev, 0);
+	struct imsm_map *map_dest = get_imsm_map(dev, MAP_0);
 	int new_disks = map_dest->num_members;
 	int dest_layout = 0;
 	int dest_chunk;
 	unsigned long long start;
-	int data_disks = imsm_num_data_members(dev, 0);
+	int data_disks = imsm_num_data_members(dev, MAP_0);
 
 	targets = malloc(new_disks * sizeof(int));
 	if (!targets)
@@ -8505,7 +8509,7 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
 	if (id == NULL)
 		return 1;
 
-	map_dest = get_imsm_map(id->dev, 0);
+	map_dest = get_imsm_map(id->dev, MAP_0);
 	new_disks = map_dest->num_members;
 
 	read_offset = (unsigned long long)
@@ -8890,7 +8894,7 @@ static int imsm_create_metadata_update_for_migration(
 	if (dev) {
 		struct imsm_map *map;
 
-		map = get_imsm_map(dev, 0);
+		map = get_imsm_map(dev, MAP_0);
 		if (map) {
 			int current_chunk_size =
 				__le16_to_cpu(map->blocks_per_strip) / 2;
@@ -9402,12 +9406,12 @@ static int imsm_manage_reshape(
 		goto abort;
 	}
 
-	map_src = get_imsm_map(dev, 1);
+	map_src = get_imsm_map(dev, MAP_1);
 	if (map_src == NULL)
 		goto abort;
 
-	ndata = imsm_num_data_members(dev, 0);
-	odata = imsm_num_data_members(dev, 1);
+	ndata = imsm_num_data_members(dev, MAP_0);
+	odata = imsm_num_data_members(dev, MAP_1);
 
 	chunk = __le16_to_cpu(map_src->blocks_per_strip) * 512;
 	old_data_stripe_length = odata * chunk;


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

* Re: [PATCH 0/9] Array degradation during reshape and rebuild (cont.)
  2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
                   ` (8 preceding siblings ...)
  2011-12-07 12:58 ` [PATCH 9/9] imsm: FIX: Use defines for device map access Adam Kwolek
@ 2011-12-08  3:15 ` NeilBrown
  9 siblings, 0 replies; 11+ messages in thread
From: NeilBrown @ 2011-12-08  3:15 UTC (permalink / raw)
  To: Adam Kwolek; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]

On Wed, 07 Dec 2011 13:57:35 +0100 Adam Kwolek <adam.kwolek@intel.com> wrote:

> The following series adds implementation details for array
> degradation during reshape and rebuild/initialization.
> 
> Series fixes problems in handling degradation during rebuild
> in imsm metadata and fixes problems noticed in applied changes..
> 
> Failing disks using sysfs (echo 1 > /sys/block/sdX/device/delete)
> mdadm does his job correctly.
> The problem is when disks are pulled physically from system.
> As workaround BBM disabling can be used /sent previously/.
> 
> 
> BR
> Adam
>   
> 
> ---
> 
> Adam Kwolek (9):
>       imsm: FIX: Use defines for device map access
>       imsm: FIX: Check correct slots on disk failure
>       imsm: FIX: Finish rebuild and initialization when missing drive is handled
>       imsm: FIX: Mark failure for rebuild
>       imsm: FIX: Add array map state transition for failures during initialization
>       imsm: FIX: Do not allow spare activation during rebuild
>       imsm: Function imsm_set_disk() rework
>       imsm: FIX: Correct ords merging in end_migration()
>       imsm: FIX: Remove longer map request
> 
> 
>  super-intel.c |  475 ++++++++++++++++++++++++++++++++++-----------------------
>  1 files changed, 285 insertions(+), 190 deletions(-)
> 

Thanks.
I've applied all of these.

I can't claim to have understood them all completely, but there was nothing
obviously wrong, so I'll assume they are right :-)

Thanks,
NeilBrown



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2011-12-08  3:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-07 12:57 [PATCH 0/9] Array degradation during reshape and rebuild (cont.) Adam Kwolek
2011-12-07 12:57 ` [PATCH 1/9] imsm: FIX: Remove longer map request Adam Kwolek
2011-12-07 12:57 ` [PATCH 2/9] imsm: FIX: Correct ords merging in end_migration() Adam Kwolek
2011-12-07 12:57 ` [PATCH 3/9] imsm: Function imsm_set_disk() rework Adam Kwolek
2011-12-07 12:58 ` [PATCH 4/9] imsm: FIX: Do not allow spare activation during rebuild Adam Kwolek
2011-12-07 12:58 ` [PATCH 5/9] imsm: FIX: Add array map state transition for failures during initialization Adam Kwolek
2011-12-07 12:58 ` [PATCH 6/9] imsm: FIX: Mark failure for rebuild Adam Kwolek
2011-12-07 12:58 ` [PATCH 7/9] imsm: FIX: Finish rebuild and initialization when missing drive is handled Adam Kwolek
2011-12-07 12:58 ` [PATCH 8/9] imsm: FIX: Check correct slots on disk failure Adam Kwolek
2011-12-07 12:58 ` [PATCH 9/9] imsm: FIX: Use defines for device map access Adam Kwolek
2011-12-08  3:15 ` [PATCH 0/9] Array degradation during reshape and rebuild (cont.) NeilBrown

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