[dm-devel] [PATCH 1/2] multipathd: Fixing add map functionality

Tejaswini Poluri tpoluri at mvista.com
Mon Jul 20 09:29:31 UTC 2015


Add map feature of multipathd tools fails as the device
is also been completely removed along with removing the map
in the remove map code.
So when add map is called we are creating the device again
in cli_add_map() using the coloasce_paths code.

Signed-off-by: Tejaswini Poluri <tpoluri at mvista.com>
---
 multipathd/cli_handlers.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index dc96c45..032a789 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -535,7 +535,7 @@ cli_add_map (void * v, char ** reply, int * len, void * data)
 	char * param = get_keyparam(v, MAP);
 	int major, minor;
 	char dev_path[PATH_SIZE];
-	char *alias;
+	char *alias, *refwwid;
 	int rc;
 
 	param = convert_dev(param, 0);
@@ -545,27 +545,33 @@ cli_add_map (void * v, char ** reply, int * len, void * data)
 		*reply = strdup("blacklisted\n");
 		*len = strlen(*reply) + 1;
 		condlog(2, "%s: map blacklisted", param);
-		return 0;
+		return 1;
 	}
+mapname:
 	minor = dm_get_minor(param);
 	if (minor < 0) {
 		condlog(2, "%s: not a device mapper table", param);
-		return 0;
 	}
 	major = dm_get_major(param);
 	if (major < 0) {
 		condlog(2, "%s: not a device mapper table", param);
-		return 0;
 	}
 	sprintf(dev_path,"dm-%d", minor);
 	alias = dm_mapname(major, minor);
 	if (!alias) {
 		condlog(2, "%s: mapname not found for %d:%d",
 			param, major, minor);
-		return 0;
+		rc = get_refwwid(param, DEV_DEVMAP, vecs->pathvec, &refwwid);
+		if (refwwid) {
+			if (coalesce_paths(vecs, NULL, refwwid, 0))
+				condlog(2, "%s: coalesce_paths failed", param);
+			dm_lib_release();
+		}
+		goto mapname;
 	}
 	rc = ev_add_map(dev_path, alias, vecs);
 	FREE(alias);
+	FREE(refwwid);
 	return rc;
 }
 
-- 
1.9.1




More information about the dm-devel mailing list