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

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