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

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