[dm-devel] [PATCH 41/42] libmultipath: refuse reloading an existing map with different WWID

mwilck at suse.com mwilck at suse.com
Thu Jul 9 10:35:12 UTC 2020


From: Martin Wilck <mwilck at suse.com>

If a map with given name (alias) already exists with a different WWID,
reloading it with a new WWID will be harmful. The existing paths would
be replaced by other, unrelated ones. The WWIDs of the new paths would
not match the map WWID, and thus sooner or later overwritten by
disassemble_map with the map's wwid.

Refuse reloading a map under such circumstances. This makes it impossible
to "swap" multipath names in a single reconfigure run, but avoiding
data corruption should be worth it.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 libmultipath/configure.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index c62807e..75e11fd 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -897,10 +897,21 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
 		return DOMAP_DRY;
 	}
 
-	if (mpp->action == ACT_CREATE &&
-	    dm_map_present(mpp->alias)) {
-		condlog(3, "%s: map already present", mpp->alias);
-		mpp->action = ACT_RELOAD;
+	if (mpp->action == ACT_CREATE && dm_map_present(mpp->alias)) {
+		char wwid[WWID_SIZE];
+
+		if (dm_get_uuid(mpp->alias, wwid, sizeof(wwid)) == 0) {
+			if (!strncmp(mpp->wwid, wwid, sizeof(wwid))) {
+				condlog(3, "%s: map already present",
+					mpp->alias);
+				mpp->action = ACT_RELOAD;
+			} else {
+				condlog(0, "%s: map \"%s\" already present with WWID %s, skipping",
+					mpp->wwid, mpp->alias, wwid);
+				condlog(0, "please check alias settings in config and bindings file");
+				mpp->action = ACT_REJECT;
+			}
+		}
 	}
 
 	switch (mpp->action) {
-- 
2.26.2





More information about the dm-devel mailing list