[PATCH v3 07/12] libmultipath: handle empty maps in dm_flush_map__

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

 



Make dm_flush_map__() remove empty devices, as long as they have
valid multipath uuids.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
Reviewed-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/devmapper.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index e5f49a5b..b0bd0d4f 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -982,11 +982,16 @@ int dm_flush_map__ (const char *mapname, int flags, int retries)
 	int udev_flags = 0;
 	char *params __attribute__((cleanup(cleanup_charp))) = NULL;
 
-	if (libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY | MAPINFO_CHECK_UUID,
+	r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY | MAPINFO_CHECK_UUID,
 			  (mapid_t) { .str = mapname },
-			  (mapinfo_t) { .target = &params }) != DMP_OK)
+			  (mapinfo_t) { .target = &params });
+	if (r != DMP_OK && r != DMP_EMPTY)
 		return DM_FLUSH_OK; /* nothing to do */
 
+	/* device mapper will not let you resume an empty device */
+	if (r == DMP_EMPTY)
+		flags &= ~DMFL_SUSPEND;
+
 	/* if the device currently has no partitions, do not
 	   run kpartx on it if you fail to delete it */
 	if (do_foreach_partmaps(mapname, has_partmap, NULL) == 0)
-- 
2.46.2





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

  Powered by Linux