Switch off 'queue_if_no_path' before removing maps
authorHannes Reinecke <hare@suse.de>
Tue, 8 Jan 2013 13:53:58 +0000 (14:53 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 8 Jan 2013 22:44:47 +0000 (23:44 +0100)
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@suse.de>
libmultipath/devmapper.c
libmultipath/devmapper.h
multipath/main.c

index 051ecb2..a6e7150 100644 (file)
@@ -706,6 +706,30 @@ _dm_flush_map (const char * mapname, int need_sync)
        return 1;
 }
 
+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)
 {
@@ -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);
index 0c2e03f..b08aa31 100644 (file)
@@ -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);
index 6208995..396c4b9 100644 (file)
@@ -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;