Blame SOURCES/0012-imsm-finish-recovery-when-drive-with-rebuild-fails.patch

5d5466
From a4e96fd8f3f0b5416783237c1cb6ee87e7eff23d Mon Sep 17 00:00:00 2001
5d5466
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
5d5466
Date: Fri, 8 Feb 2019 11:07:10 +0100
5d5466
Subject: [RHEL7.7 PATCH 12/24] imsm: finish recovery when drive with rebuild
5d5466
 fails
5d5466
5d5466
Commit d7a1fda2769b ("imsm: update metadata correctly while raid10 double
5d5466
degradation") resolves main Imsm double degradation problems but it
5d5466
omits one case. Now metadata hangs in the rebuilding state if the drive
5d5466
under rebuild is removed during recovery from double degradation.
5d5466
5d5466
The root cause of this problem is comparing new map_state with current
5d5466
and if they both are degraded assuming that nothing new happens.
5d5466
5d5466
Don't rely on map states, just check if device is failed. If the drive
5d5466
under rebuild fails then finish migration, in other cases update map
5d5466
state only (second fail means that destination map state can't be normal).
5d5466
5d5466
To avoid problems with reassembling move end_migration (called after
5d5466
double degradation successful recovery) after check if recovery really
5d5466
finished, for details see (7ce057018 "imsm: fix: rebuild does not
5d5466
continue after reboot").
5d5466
Remove redundant code responsible for finishing rebuild process. Function
5d5466
end_migration do exactly the same. Set last_checkpoint to 0, to prepare
5d5466
it for the next rebuild.
5d5466
5d5466
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
5d5466
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5d5466
---
5d5466
 super-intel.c | 26 +++++++++++---------------
5d5466
 1 file changed, 11 insertions(+), 15 deletions(-)
5d5466
5d5466
diff --git a/super-intel.c b/super-intel.c
5d5466
index d2035cc..38a1b6c 100644
5d5466
--- a/super-intel.c
5d5466
+++ b/super-intel.c
5d5466
@@ -8560,26 +8560,22 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
5d5466
 		}
5d5466
 		if (is_rebuilding(dev)) {
5d5466
 			dprintf_cont("while rebuilding ");
5d5466
-			if (map->map_state != map_state)  {
5d5466
-				dprintf_cont("map state change ");
5d5466
+			if (state & DS_FAULTY)  {
5d5466
+				dprintf_cont("removing failed drive ");
5d5466
 				if (n == map->failed_disk_num) {
5d5466
 					dprintf_cont("end migration");
5d5466
 					end_migration(dev, super, map_state);
5d5466
+					a->last_checkpoint = 0;
5d5466
 				} else {
5d5466
-					dprintf_cont("raid10 double degradation, map state change");
5d5466
+					dprintf_cont("fail detected during rebuild, changing map state");
5d5466
 					map->map_state = map_state;
5d5466
 				}
5d5466
 				super->updates_pending++;
5d5466
-			} else if (!rebuild_done)
5d5466
-				break;
5d5466
-			else if (n == map->failed_disk_num) {
5d5466
-				/* r10 double degraded to degraded transition */
5d5466
-				dprintf_cont("raid10 double degradation end migration");
5d5466
-				end_migration(dev, super, map_state);
5d5466
-				a->last_checkpoint = 0;
5d5466
-				super->updates_pending++;
5d5466
 			}
5d5466
 
5d5466
+			if (!rebuild_done)
5d5466
+				break;
5d5466
+
5d5466
 			/* check if recovery is really finished */
5d5466
 			for (mdi = a->info.devs; mdi ; mdi = mdi->next)
5d5466
 				if (mdi->recovery_start != MaxSector) {
5d5466
@@ -8588,7 +8584,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
5d5466
 				}
5d5466
 			if (recovery_not_finished) {
5d5466
 				dprintf_cont("\n");
5d5466
-				dprintf_cont("Rebuild has not finished yet, map state changes only if raid10 double degradation happens");
5d5466
+				dprintf_cont("Rebuild has not finished yet");
5d5466
 				if (a->last_checkpoint < mdi->recovery_start) {
5d5466
 					a->last_checkpoint =
5d5466
 						mdi->recovery_start;
5d5466
@@ -8598,9 +8594,9 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
5d5466
 			}
5d5466
 
5d5466
 			dprintf_cont(" Rebuild done, still degraded");
5d5466
-			dev->vol.migr_state = 0;
5d5466
-			set_migr_type(dev, 0);
5d5466
-			dev->vol.curr_migr_unit = 0;
5d5466
+			end_migration(dev, super, map_state);
5d5466
+			a->last_checkpoint = 0;
5d5466
+			super->updates_pending++;
5d5466
 
5d5466
 			for (i = 0; i < map->num_members; i++) {
5d5466
 				int idx = get_imsm_ord_tbl_ent(dev, i, MAP_0);
5d5466
-- 
5d5466
2.7.5
5d5466