@@ -892,7 +892,7 @@ int dm_find_map_by_wwid(const char *wwid, char *name, struct dm_info *dmi)
if (safe_sprintf(tmp, UUID_PREFIX "%s", wwid))
return DMP_ERR;
- return libmp_mapinfo(DM_MAP_BY_UUID,
+ return libmp_mapinfo(DM_MAP_BY_UUID | MAPINFO_MPATH_ONLY,
(mapid_t) { .str = tmp },
(mapinfo_t) { .name = name, .dmi = dmi });
}
@@ -725,7 +725,13 @@ cli_add_map (void * v, struct strbuf *reply, void * data)
condlog(2, "%s: unknown map.", param);
return -ENODEV;
}
- if (dm_find_map_by_wwid(refwwid, alias, &dmi) != DMP_OK) {
+ rc = dm_find_map_by_wwid(refwwid, alias, &dmi);
+ if (rc == DMP_NO_MATCH) {
+ condlog(2, "%s: wwid %s already in use by non-multipath device %s",
+ param, refwwid, alias);
+ return 1;
+ }
+ if (rc != DMP_OK) {
condlog(3, "%s: map not present. creating", param);
if (coalesce_paths(vecs, NULL, refwwid, FORCE_RELOAD_NONE,
CMD_NONE) != CP_OK) {
This function is only supposed to work on multipath devices (it adds the multipath uuid prefix to the passed in wwid). Check this, and adapt cli_add_map() to handle the corner case where there is a non-multipath device with a multipath uuid. Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> --- libmultipath/devmapper.c | 2 +- multipathd/cli_handlers.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-)