Blame SOURCES/0189-RHBZ-1368211-remove-retries.patch

4728c8
---
4728c8
 libmultipath/config.c      |    1 +
4728c8
 libmultipath/config.h      |    1 +
4728c8
 libmultipath/devmapper.c   |   35 +++++++++++++++++++----------------
4728c8
 libmultipath/dict.c        |   25 +++++++++++++++++++++++++
4728c8
 multipath.conf.defaults    |    1 +
4728c8
 multipath/multipath.conf.5 |    5 +++++
4728c8
 6 files changed, 52 insertions(+), 16 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/devmapper.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/devmapper.c
4728c8
+++ multipath-tools-130222/libmultipath/devmapper.c
4728c8
@@ -803,10 +803,11 @@ dm_flush_map_nopaths(const char * mapnam
4728c8
 extern int
4728c8
 dm_suspend_and_flush_map (const char * mapname)
4728c8
 {
4728c8
-	int s = 0, queue_if_no_path = 0;
4728c8
+	int need_reset = 0, queue_if_no_path = 0;
4728c8
 	unsigned long long mapsize;
4728c8
 	char params[PARAMS_SIZE] = {0};
4728c8
 	int udev_flags = 0;
4728c8
+	int retries = conf->remove_retries;
4728c8
 
4728c8
 	if (!dm_is_mpath(mapname))
4728c8
 		return 0; /* nothing to do */
4728c8
@@ -821,22 +822,24 @@ dm_suspend_and_flush_map (const char * m
4728c8
 			queue_if_no_path = 1;
4728c8
 	}
4728c8
 
4728c8
-	if (queue_if_no_path)
4728c8
-		s = dm_queue_if_no_path((char *)mapname, 0);
4728c8
-	/* Leave queue_if_no_path alone if unset failed */
4728c8
-	if (s)
4728c8
-		queue_if_no_path = 0;
4728c8
-	else
4728c8
-		s = dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0, 0);
4728c8
-
4728c8
-	if (!dm_flush_map(mapname)) {
4728c8
-		condlog(4, "multipath map %s removed", mapname);
4728c8
-		return 0;
4728c8
-	}
4728c8
+	if (queue_if_no_path && dm_queue_if_no_path((char *)mapname, 0) == 0)
4728c8
+		need_reset = 1;
4728c8
+
4728c8
+	do {
4728c8
+		if (!queue_if_no_path || need_reset)
4728c8
+			dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0, 0);
4728c8
+
4728c8
+		if (!dm_flush_map(mapname)) {
4728c8
+			condlog(4, "multipath map %s removed", mapname);
4728c8
+			return 0;
4728c8
+		}
4728c8
+		dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname, udev_flags);
4728c8
+		if (retries)
4728c8
+			sleep(1);
4728c8
+	} while (retries-- > 0);
4728c8
 	condlog(2, "failed to remove multipath map %s", mapname);
4728c8
-	dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname, udev_flags);
4728c8
-	if (queue_if_no_path)
4728c8
-		s = dm_queue_if_no_path((char *)mapname, 1);
4728c8
+	if (need_reset)
4728c8
+		dm_queue_if_no_path((char *)mapname, 1);
4728c8
 	return 1;
4728c8
 }
4728c8
 
4728c8
Index: multipath-tools-130222/libmultipath/config.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/config.c
4728c8
+++ multipath-tools-130222/libmultipath/config.c
4728c8
@@ -680,6 +680,7 @@ load_config (char * file, struct udev *u
4728c8
 	conf->new_bindings_in_boot = 0;
4728c8
 	conf->uev_wait_timeout = DEFAULT_UEV_WAIT_TIMEOUT;
4728c8
 	conf->skip_kpartx = DEFAULT_SKIP_KPARTX;
4728c8
+	conf->remove_retries = 0;
4728c8
 
4728c8
 	/*
4728c8
 	 * preload default hwtable
4728c8
Index: multipath-tools-130222/libmultipath/config.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/config.h
4728c8
+++ multipath-tools-130222/libmultipath/config.h
4728c8
@@ -146,6 +146,7 @@ struct config {
4728c8
 	int delayed_reconfig;
4728c8
 	int uev_wait_timeout;
4728c8
 	int skip_kpartx;
4728c8
+	int remove_retries;
4728c8
 	unsigned int version[3];
4728c8
 
4728c8
 	char * dev;
4728c8
Index: multipath-tools-130222/libmultipath/dict.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/dict.c
4728c8
+++ multipath-tools-130222/libmultipath/dict.c
4728c8
@@ -935,6 +935,24 @@ def_new_bindings_in_boot_handler(vector
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+static int
4728c8
+def_remove_retries_handler(vector strvec)
4728c8
+{
4728c8
+	char *buff;
4728c8
+
4728c8
+	buff = set_value(strvec);
4728c8
+
4728c8
+	if (!buff)
4728c8
+		return 1;
4728c8
+
4728c8
+	conf->remove_retries = atoi(buff);
4728c8
+	if (conf->remove_retries < 0)
4728c8
+		conf->remove_retries = 0;
4728c8
+	FREE(buff);
4728c8
+
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 /*
4728c8
  * blacklist block handlers
4728c8
  */
4728c8
@@ -3405,6 +3423,12 @@ snprint_def_new_bindings_in_boot(char *
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
+snprint_def_remove_retries (char * buff, int len, void * data)
4728c8
+{
4728c8
+	return snprintf(buff, len, "%i", conf->remove_retries);
4728c8
+}
4728c8
+
4728c8
+static int
4728c8
 snprint_ble_simple (char * buff, int len, void * data)
4728c8
 {
4728c8
 	struct blentry * ble = (struct blentry *)data;
4728c8
@@ -3483,6 +3507,7 @@ init_keywords(void)
4728c8
 	install_keyword("retrigger_delay", &def_retrigger_delay_handler, &snprint_def_retrigger_delay);
4728c8
 	install_keyword("missing_uev_wait_timeout", &def_uev_wait_timeout_handler, &snprint_def_uev_wait_timeout);
4728c8
 	install_keyword("new_bindings_in_boot", &def_new_bindings_in_boot_handler, &snprint_def_new_bindings_in_boot);
4728c8
+	install_keyword("remove_retries", &def_remove_retries_handler, &snprint_def_remove_retries);
4728c8
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
4728c8
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
4728c8
 	__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
4728c8
Index: multipath-tools-130222/multipath.conf.defaults
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipath.conf.defaults
4728c8
+++ multipath-tools-130222/multipath.conf.defaults
4728c8
@@ -41,6 +41,7 @@
4728c8
 #	retrigger_delay 10
4728c8
 #	missing_uev_wait_timeout 30
4728c8
 #	new_bindings_in_boot no
4728c8
+#	remove_retries 0
4728c8
 #}
4728c8
 #blacklist {
4728c8
 #	devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
4728c8
Index: multipath-tools-130222/multipath/multipath.conf.5
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipath/multipath.conf.5
4728c8
+++ multipath-tools-130222/multipath/multipath.conf.5
4728c8
@@ -556,6 +556,11 @@ user_friendly_names.  When multipathd is
4728c8
 regular filesystem, the device will be renamed to a user_friendly_name. The
4728c8
 default is
4728c8
 .I no
4728c8
+.TP
4728c8
+.B remove_retries
4728c8
+This sets how may times multipath will retry removing a device that is in-use.
4728c8
+Between each attempt, multipath will sleep 1 second. The default is
4728c8
+.I 0
4728c8
 .
4728c8
 .SH "blacklist section"
4728c8
 The