diff mbox series

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

Message ID 20241126184224.855459-8-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: Benjamin Marzinski
Headers show
Series multipath-tools: Handle tableless DM devices | expand

Commit Message

Benjamin Marzinski Nov. 26, 2024, 6:42 p.m. UTC
Make dm_flush_map__() remove empty devices, as long as they have
valid multipath uuids.

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

Patch

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)