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

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