diff -rup multipath-tool_0.4.8.orig/libmultipath/devmapper.c multipath-tool_0.4.8_add_map/libmultipath/devmapper.c --- multipath-tool_0.4.8.orig/libmultipath/devmapper.c 2015-06-16 12:41:45.513994000 +0530 +++ multipath-tool_0.4.8_add_map/libmultipath/devmapper.c 2015-06-18 13:00:40.321060152 +0530 @@ -503,6 +503,27 @@ dm_flush_map (char * mapname, char * typ } extern int +dm_remove_map (char * mapname, char * type) +{ + condlog(2, "%s",__func__); + if (!dm_map_present(mapname)) + return 0; + + if (dm_type(mapname, type) <= 0) + return 1; + + if (dm_remove_partmaps(mapname)) + return 1; + + if (dm_get_opencount(mapname)) { + condlog(2, "%s: map in use", mapname); + return 1; + } + condlog(4, "multipath map %s removed", mapname); + return 0; +} + +extern int dm_flush_maps (char * type) { int r = 0; diff -rup multipath-tool_0.4.8.orig/libmultipath/devmapper.h multipath-tool_0.4.8_add_map/libmultipath/devmapper.h --- multipath-tool_0.4.8.orig/libmultipath/devmapper.h 2015-05-12 17:50:48.488293000 +0530 +++ multipath-tool_0.4.8_add_map/libmultipath/devmapper.h 2015-06-18 11:48:41.908950878 +0530 @@ -8,6 +8,7 @@ int dm_get_map(char *, unsigned long lon int dm_get_status(char *, char *); int dm_type(char *, char *); int dm_flush_map (char *, char *); +int dm_remove_map (char *, char *); int dm_flush_maps (char *); int dm_fail_path(char * mapname, char * path); int dm_reinstate_path(char * mapname, char * path); diff -rup multipath-tool_0.4.8.orig/multipathd/main.c multipath-tool_0.4.8_add_map/multipathd/main.c --- multipath-tool_0.4.8.orig/multipathd/main.c 2015-05-12 17:50:48.496293000 +0530 +++ multipath-tool_0.4.8_add_map/multipathd/main.c 2015-06-18 13:11:03.917075932 +0530 @@ -175,7 +175,31 @@ sync_maps_state(vector mpvec) vector_foreach_slot (mpvec, mpp, i) sync_map_state(mpp); } +static int +discard_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_remove_map(mpp->alias, DEFAULT_TARGET)) { + /* + * May not really be an error -- if the map was already flushed + * from the device mapper by dmsetup(8) for instance. + */ + condlog(0, "%s: can't flush", mpp->alias); + return 1; + } + else { + dm_lib_release(); + condlog(3, "%s: devmap removed", mpp->alias); + } + orphan_paths(vecs->pathvec, mpp); + remove_map(mpp, vecs, stop_waiter_thread, 1); + + return 0; +} static int flush_map(struct multipath * mpp, struct vectors * vecs) { @@ -294,7 +318,8 @@ ev_remove_map (char * devname, struct ve devname); return 0; } - flush_map(mpp, vecs); + //flush_map(mpp, vecs); + discard_map(mpp, vecs); return 0; }