Blame SOURCES/0059-UP-flush-failure-queueing.patch

671555
---
671555
 libmultipath/devmapper.c |   21 +++++++++++++++++----
671555
 libmultipath/devmapper.h |    2 +-
671555
 2 files changed, 18 insertions(+), 5 deletions(-)
671555
671555
Index: multipath-tools-130222/libmultipath/devmapper.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmultipath/devmapper.c
671555
+++ multipath-tools-130222/libmultipath/devmapper.c
671555
@@ -363,7 +363,7 @@ out:
671555
 }
671555
 
671555
 extern int
671555
-dm_get_map(char * name, unsigned long long * size, char * outparams)
671555
+dm_get_map(const char * name, unsigned long long * size, char * outparams)
671555
 {
671555
 	int r = 1;
671555
 	struct dm_task *dmt;
671555
@@ -682,7 +682,9 @@ _dm_flush_map (const char * mapname, int
671555
 extern int
671555
 dm_suspend_and_flush_map (const char * mapname)
671555
 {
671555
-	int s;
671555
+	int s = 0, queue_if_no_path = 0;
671555
+	unsigned long long mapsize;
671555
+	char params[PARAMS_SIZE] = {0};
671555
 
671555
 	if (!dm_map_present(mapname))
671555
 		return 0;
671555
@@ -690,8 +692,17 @@ dm_suspend_and_flush_map (const char * m
671555
 	if (dm_type(mapname, TGT_MPATH) <= 0)
671555
 		return 0; /* nothing to do */
671555
 
671555
-	s = dm_queue_if_no_path((char *)mapname, 0);
671555
-	if (!s)
671555
+	if (!dm_get_map(mapname, &mapsize, params)) {
671555
+		if (strstr(params, "queue_if_no_path"))
671555
+			queue_if_no_path = 1;
671555
+	}
671555
+
671555
+	if (queue_if_no_path)
671555
+		s = dm_queue_if_no_path((char *)mapname, 0);
671555
+	/* Leave queue_if_no_path alone if unset failed */
671555
+	if (s)
671555
+		queue_if_no_path = 0;
671555
+	else
671555
 		s = dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0);
671555
 
671555
 	if (!dm_flush_map(mapname)) {
671555
@@ -700,6 +711,8 @@ dm_suspend_and_flush_map (const char * m
671555
 	}
671555
 	condlog(2, "failed to remove multipath map %s", mapname);
671555
 	dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname);
671555
+	if (queue_if_no_path)
671555
+		s = dm_queue_if_no_path((char *)mapname, 1);
671555
 	return 1;
671555
 }
671555
 
671555
Index: multipath-tools-130222/libmultipath/devmapper.h
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmultipath/devmapper.h
671555
+++ multipath-tools-130222/libmultipath/devmapper.h
671555
@@ -14,7 +14,7 @@ int dm_simplecmd_noflush (int, const cha
671555
 int dm_addmap_create (struct multipath *mpp, char *params);
671555
 int dm_addmap_reload (struct multipath *mpp, char *params);
671555
 int dm_map_present (const char *);
671555
-int dm_get_map(char *, unsigned long long *, char *);
671555
+int dm_get_map(const char *, unsigned long long *, char *);
671555
 int dm_get_status(char *, char *);
671555
 int dm_type(const char *, char *);
671555
 int _dm_flush_map (const char *, int);