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

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