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

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