[PATCH v2 09/13] libmultipath: remove recursive calls in partmap_funcs

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

 



cancel_remove_partmap() and rename_partmap() both could end up calling
do_foreach_partmaps() with the partition instead of the original
multipath device. This won't ever do anything, since
do_foreach_partmaps() checks that it's called with a multipath device.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/devmapper.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 0df9ee40..daaeebb4 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -1421,8 +1421,6 @@ dm_remove_partmaps (const char * mapname, int flags)
 static int
 cancel_remove_partmap (const char *name, void *unused __attribute__((unused)))
 {
-	if (dm_get_opencount(name))
-		dm_cancel_remove_partmaps(name);
 	if (dm_message(name, "@cancel_deferred_remove") != 0)
 		condlog(0, "%s: can't cancel deferred remove: %s", name,
 			strerror(errno));
@@ -1481,6 +1479,9 @@ struct rename_data {
 	char *delim;
 };
 
+static int
+dm_rename__(const char *old, char *new, int skip_kpartx);
+
 static int
 rename_partmap (const char *name, void *data)
 {
@@ -1492,7 +1493,7 @@ rename_partmap (const char *name, void *data)
 		return 0;
 	for (offset = strlen(rd->old); name[offset] && !(isdigit(name[offset])); offset++); /* do nothing */
 	if (asprintf(&buff, "%s%s%s", rd->new, rd->delim, name + offset) >= 0) {
-		dm_rename(name, buff, rd->delim, SKIP_KPARTX_OFF);
+		dm_rename__(name, buff, SKIP_KPARTX_OFF);
 		free(buff);
 		condlog(4, "partition map %s renamed", name);
 	} else
@@ -1519,17 +1520,14 @@ dm_rename_partmaps (const char * old, char * new, char *delim)
 	return do_foreach_partmaps(old, rename_partmap, &rd);
 }
 
-int
-dm_rename (const char * old, char * new, char *delim, int skip_kpartx)
+static int
+dm_rename__(const char *old, char *new, int skip_kpartx)
 {
 	int r = 0;
 	struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL;
 	uint32_t cookie = 0;
 	uint16_t udev_flags = DM_UDEV_DISABLE_LIBRARY_FALLBACK | ((skip_kpartx == SKIP_KPARTX_ON)? MPATH_UDEV_NO_KPARTX_FLAG : 0);
 
-	if (dm_rename_partmaps(old, new, delim))
-		return r;
-
 	if (!(dmt = libmp_dm_task_create(DM_DEVICE_RENAME)))
 		return r;
 
@@ -1550,6 +1548,14 @@ dm_rename (const char * old, char * new, char *delim, int skip_kpartx)
 	return r;
 }
 
+int
+dm_rename (const char * old, char * new, char *delim, int skip_kpartx)
+{
+	if (dm_rename_partmaps(old, new, delim))
+		return 0;
+	return dm_rename__(old, new, skip_kpartx);
+}
+
 void dm_reassign_deps(char *table, const char *dep, const char *newdep)
 {
 	char *n, *newtable;
-- 
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