File multipath-tools-switch-off-queue_if_no_path-before-removing-maps of Package multipath-tools

From f77cfeb6547d2dbadfa81bae402ccebbaca58cae Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 19 Feb 2009 16:20:51 +0100
Subject: [PATCH] Switch off 'queue_if_no_path' before removing maps

Before we try to flush a map we have to switch off the
'queue_if_no_path' setting to flush any outstanding I/O.

References: 475523

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 libmultipath/configure.c |    4 ++--
 libmultipath/devmapper.c |    9 ++++++---
 libmultipath/devmapper.h |    2 +-
 multipath/main.c         |    2 +-
 multipathd/main.c        |    4 ++--
 5 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index d1e26a1..f6d8e05 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -158,7 +158,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
 
 	if (!find_mp_by_wwid(curmp, mpp->wwid)) {
 		condlog(2, "%s: remove (wwid changed)", cmpp->alias);
-		dm_flush_map(mpp->alias);
+		dm_flush_map(mpp->alias, 0);
 		strncat(cmpp->wwid, mpp->wwid, WWID_SIZE);
 		drop_multipath(curmp, cmpp->wwid, KEEP_PATHS);
 		mpp->action = ACT_CREATE;
@@ -565,7 +565,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
 
 			remove_map(mpp, vecs, 0);
 
-			if (dm_flush_map(mpp->alias))
+			if (dm_flush_map(mpp->alias, 0))
 				condlog(2, "%s: remove failed (dead)",
 					mpp->alias);
 			else
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index c848ea8..d173cc8 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -234,7 +234,7 @@ _dm_addmap_create (const char *name, const char *params,
 	if (!r && dm_map_present(name)) {
 		condlog(3, "%s: failed to load map (a path might be in use)",
 			name);
-		dm_flush_map(name);
+		dm_flush_map(name, 0);
 	}
 	return r;
 }
@@ -548,7 +548,7 @@ out:
 }
 
 extern int
-dm_flush_map (const char * mapname)
+dm_flush_map (const char * mapname, int flush_io)
 {
 	int r;
 
@@ -566,6 +566,9 @@ dm_flush_map (const char * mapname)
 		return 1;
 	}
 
+	if (flush_io && dm_queue_if_no_path((char *)mapname, 0))
+		condlog(3, "%s: could not unset queue_if_no_path", mapname);
+
 	r = dm_simplecmd(DM_DEVICE_REMOVE, mapname, 0);
 
 	if (r) {
@@ -598,7 +601,7 @@ dm_flush_maps (void)
 		goto out;
 
 	do {
-		r += dm_flush_map(names->name);
+		r += dm_flush_map(names->name, 1);
 		next = names->next;
 		names = (void *) names + next;
 	} while (next);
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index 0c7b6b6..0e55b1a 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -16,7 +16,7 @@ int dm_map_present (const char *);
 int dm_get_map(char *, unsigned long long *, char *);
 int dm_get_status(char *, char *);
 int dm_type(const char *, char *);
-int dm_flush_map (const char *);
+int dm_flush_map (const char *, int);
 int dm_flush_maps (void);
 int dm_fail_path(char * mapname, char * path);
 int dm_reinstate_path(char * mapname, char * path);
diff --git a/multipath/main.c b/multipath/main.c
index 49b5619..340a761 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -499,7 +499,7 @@ main (int argc, char *argv[])
 
 	if (conf->remove == FLUSH_ONE) {
 		if (conf->dev_type == DEV_DEVMAP)
-			dm_flush_map(conf->dev);
+			dm_flush_map(conf->dev, 1);
 		else
 			condlog(0, "must provide a map name to remove");
 
diff --git a/multipathd/main.c b/multipathd/main.c
index 71acc05..d2a31c2 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -125,7 +125,7 @@ coalesce_maps(struct vectors *vecs, vector nmpv)
 			 * remove all current maps not allowed by the
 			 * current configuration
 			 */
-			if (dm_flush_map(ompp->alias)) {
+			if (dm_flush_map(ompp->alias, 0)) {
 				condlog(0, "%s: unable to flush devmap",
 					ompp->alias);
 				/*
@@ -198,7 +198,7 @@ flush_map(struct multipath * mpp, struct vectors * vecs)
 	 * clear references to this map before flushing so we can ignore
 	 * the spurious uevent we may generate with the dm_flush_map call below
 	 */
-	if (dm_flush_map(mpp->alias)) {
+	if (dm_flush_map(mpp->alias, 0)) {
 		/*
 		 * May not really be an error -- if the map was already flushed
 		 * from the device mapper by dmsetup(8) for instance.
-- 
1.6.0.2

openSUSE Build Service is sponsored by