[PATCH 20/42] Switch off 'queue_if_no_path' before removing maps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
---
 libmultipath/devmapper.c |   26 +++++++++++++++++++++++++-
 libmultipath/devmapper.h |    1 +
 multipath/main.c         |    6 +++---
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 051ecb2..a6e7150 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -707,6 +707,30 @@ _dm_flush_map (const char * mapname, int need_sync)
 }
 
 extern int
+dm_suspend_and_flush_map (const char * mapname)
+{
+	int s;
+
+	if (!dm_map_present(mapname))
+		return 0;
+
+	if (dm_type(mapname, TGT_MPATH) <= 0)
+		return 0; /* nothing to do */
+
+	s = dm_queue_if_no_path((char *)mapname, 0);
+	if (!s)
+		s = dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0);
+
+	if (!dm_flush_map(mapname)) {
+		condlog(4, "multipath map %s removed", mapname);
+		return 0;
+	}
+	condlog(2, "failed to remove multipath map %s", mapname);
+	dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname);
+	return 1;
+}
+
+extern int
 dm_flush_maps (void)
 {
 	int r = 0;
@@ -729,7 +753,7 @@ dm_flush_maps (void)
 		goto out;
 
 	do {
-		r |= dm_flush_map(names->name);
+		r |= dm_suspend_and_flush_map(names->name);
 		next = names->next;
 		names = (void *) names + next;
 	} while (next);
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index 0c2e03f..b08aa31 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -22,6 +22,7 @@ int dm_type(const char *, char *);
 int _dm_flush_map (const char *, int);
 #define dm_flush_map(mapname) _dm_flush_map(mapname, 1)
 #define dm_flush_map_nosync(mapname) _dm_flush_map(mapname, 0)
+int dm_suspend_and_flush_map(const char * mapname);
 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 6208995..396c4b9 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -555,9 +555,9 @@ main (int argc, char *argv[])
 		goto out;
 	}
 	if (conf->remove == FLUSH_ONE) {
-		if (conf->dev_type == DEV_DEVMAP)
-			r = dm_flush_map(conf->dev);
-		else
+		if (conf->dev_type == DEV_DEVMAP) {
+			r = dm_suspend_and_flush_map(conf->dev);
+		} else
 			condlog(0, "must provide a map name to remove");
 
 		goto out;
-- 
1.7.4.2

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux