Blame SOURCES/mdadm-3.2.6-mdmon-clear-safe_mode_delay-on-shutdown.patch

fc6001
From 2ef219630b7e1baa72fce420b6bc41cf8071c5e8 Mon Sep 17 00:00:00 2001
fc6001
From: NeilBrown <neilb@suse.de>
fc6001
Date: Thu, 1 Aug 2013 15:45:17 +1000
fc6001
Subject: [PATCH] mdmon: clear safe_mode_delay on shutdown
fc6001
fc6001
When we receive a signal, set the safemode delay to v.small
fc6001
so that we can ge clean arrays and exit quickly
fc6001
fc6001
Signed-off-by: NeilBrown <neilb@suse.de>o
fc6001
---
fc6001
 managemon.c | 18 +++++++++++++++++-
fc6001
 1 file changed, 17 insertions(+), 1 deletion(-)
fc6001
fc6001
diff --git a/managemon.c b/managemon.c
fc6001
index 40c863f..6cd93e5 100644
fc6001
--- a/managemon.c
fc6001
+++ b/managemon.c
fc6001
@@ -492,6 +492,11 @@ static void manage_member(struct mdstat_ent *mdstat,
fc6001
 	if (a->container == NULL)
fc6001
 		return;
fc6001
 
fc6001
+	if (sigterm && a->info.safe_mode_delay > 1) {
fc6001
+		sysfs_set_safemode(&a->info, 1);
fc6001
+		a->info.safe_mode_delay = 1;
fc6001
+	}
fc6001
+
fc6001
 	/* We don't check the array while any update is pending, as it
fc6001
 	 * might container a change (such as a spare assignment) which
fc6001
 	 * could affect our decisions.
fc6001
@@ -646,7 +651,8 @@ static void manage_new(struct mdstat_ent *mdstat,
fc6001
 
fc6001
 	mdi = sysfs_read(-1, mdstat->devnum,
fc6001
 			 GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
fc6001
-			 GET_DEGRADED|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE);
fc6001
+			 GET_DEGRADED|GET_SAFEMODE|
fc6001
+			 GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE);
fc6001
 
fc6001
 	new = malloc(sizeof(*new));
fc6001
 
fc6001
@@ -692,6 +698,16 @@ static void manage_new(struct mdstat_ent *mdstat,
fc6001
 	dprintf("%s: inst: %d action: %d state: %d\n", __func__, atoi(inst),
fc6001
 		new->action_fd, new->info.state_fd);
fc6001
 
fc6001
+	if (sigterm)
fc6001
+		new->info.safe_mode_delay = 1;
fc6001
+	else if (mdi->safe_mode_delay >= 50)
fc6001
+		/* Normal start, mdadm set this. */
fc6001
+		new->info.safe_mode_delay = mdi->safe_mode_delay;
fc6001
+	else
fc6001
+		/* Restart, just pick a number */
fc6001
+		new->info.safe_mode_delay = 5000;
fc6001
+	sysfs_set_safemode(&new->info, new->info.safe_mode_delay);
fc6001
+
fc6001
 	/* reshape_position is set by mdadm in sysfs
fc6001
 	 * read this information for new arrays only (empty victim)
fc6001
 	 */