dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch

8fbece
From d7a1fda2769ba272d89de6caeab35d52b73a9c3c Mon Sep 17 00:00:00 2001
8fbece
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
8fbece
Date: Wed, 17 Oct 2018 12:11:41 +0200
8fbece
Subject: [RHEL7.7 PATCH 06/24] imsm: update metadata correctly while raid10
8fbece
 double degradation
8fbece
8fbece
Mdmon calls end_migration() when map state changes from normal to
8fbece
degraded. It is not valid because in raid 10 double degradation case
8fbece
mdmon breaks checkpointing but array is still rebuilding.
8fbece
In this case mdmon has to mark map as degraded and continues marking
8fbece
recovery checkpoint in metadata. Migration can be finished only if newly
8fbece
failed device is a rebuilding device.
8fbece
8fbece
Add catching double degraded to degraded transition. Migration is
8fbece
finished but map state doesn't change, array is still degraded.
8fbece
8fbece
Update failed_disk_num correctly. If double degradation
8fbece
happens rebuild will start on the lowest slot, but this variable points
8fbece
to the first failed slot. If second fail happens while rebuild this
8fbece
variable shouldn't be updated until rebuild is not finished.
8fbece
8fbece
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
8fbece
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
8fbece
---
8fbece
 super-intel.c | 25 +++++++++++++++++++------
8fbece
 1 file changed, 19 insertions(+), 6 deletions(-)
8fbece
8fbece
diff --git a/super-intel.c b/super-intel.c
8fbece
index 6438987..d2035cc 100644
8fbece
--- a/super-intel.c
8fbece
+++ b/super-intel.c
8fbece
@@ -8136,7 +8136,8 @@ static int mark_failure(struct intel_super *super,
8fbece
 			set_imsm_ord_tbl_ent(map2, slot2,
8fbece
 					     idx | IMSM_ORD_REBUILD);
8fbece
 	}
8fbece
-	if (map->failed_disk_num == 0xff)
8fbece
+	if (map->failed_disk_num == 0xff ||
8fbece
+		(!is_rebuilding(dev) && map->failed_disk_num > slot))
8fbece
 		map->failed_disk_num = slot;
8fbece
 
8fbece
 	clear_disk_badblocks(super->bbm_log, ord_to_idx(ord));
8fbece
@@ -8558,13 +8559,25 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
8fbece
 			break;
8fbece
 		}
8fbece
 		if (is_rebuilding(dev)) {
8fbece
-			dprintf_cont("while rebuilding.");
8fbece
+			dprintf_cont("while rebuilding ");
8fbece
 			if (map->map_state != map_state)  {
8fbece
-				dprintf_cont(" Map state change");
8fbece
-				end_migration(dev, super, map_state);
8fbece
+				dprintf_cont("map state change ");
8fbece
+				if (n == map->failed_disk_num) {
8fbece
+					dprintf_cont("end migration");
8fbece
+					end_migration(dev, super, map_state);
8fbece
+				} else {
8fbece
+					dprintf_cont("raid10 double degradation, map state change");
8fbece
+					map->map_state = map_state;
8fbece
+				}
8fbece
 				super->updates_pending++;
8fbece
-			} else if (!rebuild_done) {
8fbece
+			} else if (!rebuild_done)
8fbece
 				break;
8fbece
+			else if (n == map->failed_disk_num) {
8fbece
+				/* r10 double degraded to degraded transition */
8fbece
+				dprintf_cont("raid10 double degradation end migration");
8fbece
+				end_migration(dev, super, map_state);
8fbece
+				a->last_checkpoint = 0;
8fbece
+				super->updates_pending++;
8fbece
 			}
8fbece
 
8fbece
 			/* check if recovery is really finished */
8fbece
@@ -8575,7 +8588,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
8fbece
 				}
8fbece
 			if (recovery_not_finished) {
8fbece
 				dprintf_cont("\n");
8fbece
-				dprintf("Rebuild has not finished yet, state not changed");
8fbece
+				dprintf_cont("Rebuild has not finished yet, map state changes only if raid10 double degradation happens");
8fbece
 				if (a->last_checkpoint < mdi->recovery_start) {
8fbece
 					a->last_checkpoint =
8fbece
 						mdi->recovery_start;
8fbece
-- 
8fbece
2.7.5
8fbece