Blame SOURCES/0130-libmultipath-cleanup-ACT_CREATE-code-in-select_actio.patch

2e39a4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2e39a4
From: Benjamin Marzinski <bmarzins@redhat.com>
2e39a4
Date: Tue, 31 Jan 2023 10:35:10 -0600
2e39a4
Subject: [PATCH] libmultipath: cleanup ACT_CREATE code in select_action
2e39a4
2e39a4
Combine the two separate blocks that set ACT_CREATE into one.
2e39a4
2e39a4
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2e39a4
---
2e39a4
 libmultipath/configure.c | 38 +++++++++++++++++---------------------
2e39a4
 1 file changed, 17 insertions(+), 21 deletions(-)
2e39a4
2e39a4
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
2e39a4
index ecf24f95..303d2380 100644
2e39a4
--- a/libmultipath/configure.c
2e39a4
+++ b/libmultipath/configure.c
2e39a4
@@ -693,33 +693,29 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
2e39a4
 	cmpp = find_mp_by_wwid(curmp, mpp->wwid);
2e39a4
 	cmpp_by_name = find_mp_by_alias(curmp, mpp->alias);
2e39a4
 
2e39a4
-	if (!cmpp_by_name) {
2e39a4
-		if (cmpp) {
2e39a4
-			condlog(2, "%s: rename %s to %s", mpp->wwid,
2e39a4
-				cmpp->alias, mpp->alias);
2e39a4
-			strlcpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
2e39a4
-			mpp->action = ACT_RENAME;
2e39a4
-			if (force_reload) {
2e39a4
-				mpp->force_udev_reload = 1;
2e39a4
-				mpp->action = ACT_FORCERENAME;
2e39a4
-			}
2e39a4
-			return;
2e39a4
+	if (!cmpp) {
2e39a4
+		if (cmpp_by_name) {
2e39a4
+			condlog(1, "%s: can't use alias \"%s\" used by %s, falling back to WWID",
2e39a4
+				mpp->wwid, mpp->alias, cmpp_by_name->wwid);
2e39a4
+			/* We can do this because wwid wasn't found */
2e39a4
+			free(mpp->alias);
2e39a4
+			mpp->alias = strdup(mpp->wwid);
2e39a4
 		}
2e39a4
 		mpp->action = ACT_CREATE;
2e39a4
-		condlog(3, "%s: set ACT_CREATE (map does not exist)",
2e39a4
-			mpp->alias);
2e39a4
+		condlog(3, "%s: set ACT_CREATE (map does not exist%s)",
2e39a4
+			mpp->alias, cmpp_by_name ? ", name changed" : "");
2e39a4
 		return;
2e39a4
 	}
2e39a4
 
2e39a4
-	if (!cmpp) {
2e39a4
-		condlog(1, "%s: can't use alias \"%s\" used by %s, falling back to WWID",
2e39a4
-			mpp->wwid, mpp->alias, cmpp_by_name->wwid);
2e39a4
-		/* We can do this because wwid wasn't found */
2e39a4
-		free(mpp->alias);
2e39a4
-		mpp->alias = strdup(mpp->wwid);
2e39a4
-		mpp->action = ACT_CREATE;
2e39a4
-		condlog(3, "%s: set ACT_CREATE (map does not exist, name changed)",
2e39a4
+	if (!cmpp_by_name) {
2e39a4
+		condlog(2, "%s: rename %s to %s", mpp->wwid, cmpp->alias,
2e39a4
 			mpp->alias);
2e39a4
+		strlcpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
2e39a4
+		mpp->action = ACT_RENAME;
2e39a4
+		if (force_reload) {
2e39a4
+			mpp->force_udev_reload = 1;
2e39a4
+			mpp->action = ACT_FORCERENAME;
2e39a4
+		}
2e39a4
 		return;
2e39a4
 	}
2e39a4