File multipath-tools-terminate-io-before-flush of Package multipath-tools
From 816cc2cef69cfe3c9dc3439a51e8cb67638625db Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 13 Mar 2009 14:06:33 +0100
Subject: [PATCH] Terminate all outstanding I/O when flushing maps
When we're flushing a map we should be terminating all I/O.
Normally this would've been done by DM_DEVICE_REMOVE, but we're
checking for the use count before that. That will give us a false
positive if the I/O is still not flushed. And we can't remove
the use count check here as the map might really be in use by
someone else. So we'll have to do an explicit suspend/resume
cycle to flush all outstanding I/O.
References: bnc#475523
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/devmapper.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 572f6e1..2ab6ab6 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -558,9 +558,17 @@ dm_flush_map (const char * mapname, int flush_io)
if (dm_type(mapname, TGT_MPATH) <= 0)
return 1;
- if (flush_io && dm_queue_if_no_path((char *)mapname, 0))
- condlog(3, "%s: could not unset queue_if_no_path", mapname);
-
+ if (flush_io) {
+ if (!dm_queue_if_no_path((char *)mapname, 0)) {
+ /*
+ * Do a suspend/resume cycle here to
+ * flush all outstanding I/Os
+ */
+ dm_simplecmd(DM_DEVICE_SUSPEND, mapname, 0);
+ dm_simplecmd(DM_DEVICE_RESUME, mapname, 0);
+ } else
+ condlog(3, "%s: could not unset queue_if_no_path", mapname);
+ }
if (dm_remove_partmaps(mapname))
return 1;
--
1.6.0.2