Blame SOURCES/0062-multipathd-factor-out-the-code-to-flush-a-map-with-n.patch

86e138
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
86e138
From: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Date: Tue, 9 Aug 2022 16:46:26 -0500
86e138
Subject: [PATCH] multipathd: factor out the code to flush a map with no paths
86e138
86e138
The code to flush a multipath device because all of its paths have
86e138
been removed will be used by another caller, so factor it out of
86e138
ev_remove_path().
86e138
86e138
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Reviewed-by: Martin Wilck <mwilck@suse.com>
86e138
---
86e138
 multipathd/main.c | 56 ++++++++++++++++++++++++-----------------------
86e138
 1 file changed, 29 insertions(+), 27 deletions(-)
86e138
86e138
diff --git a/multipathd/main.c b/multipathd/main.c
86e138
index ed2515e5..b00eae3f 100644
86e138
--- a/multipathd/main.c
86e138
+++ b/multipathd/main.c
86e138
@@ -488,6 +488,30 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)
86e138
 	return 0;
86e138
 }
86e138
 
86e138
+static bool
86e138
+flush_map_nopaths(struct multipath *mpp, struct vectors *vecs) {
86e138
+	char alias[WWID_SIZE];
86e138
+
86e138
+	/*
86e138
+	 * flush_map will fail if the device is open
86e138
+	 */
86e138
+	strlcpy(alias, mpp->alias, WWID_SIZE);
86e138
+	if (mpp->flush_on_last_del == FLUSH_ENABLED) {
86e138
+		condlog(2, "%s Last path deleted, disabling queueing",
86e138
+			mpp->alias);
86e138
+		mpp->retry_tick = 0;
86e138
+		mpp->no_path_retry = NO_PATH_RETRY_FAIL;
86e138
+		mpp->disable_queueing = 1;
86e138
+		mpp->stat_map_failures++;
86e138
+		dm_queue_if_no_path(mpp->alias, 0);
86e138
+	}
86e138
+	if (!flush_map(mpp, vecs, 1)) {
86e138
+		condlog(2, "%s: removed map after removing all paths", alias);
86e138
+		return true;
86e138
+	}
86e138
+	return false;
86e138
+}
86e138
+
86e138
 static int
86e138
 update_map (struct multipath *mpp, struct vectors *vecs, int new_map)
86e138
 {
86e138
@@ -1247,34 +1271,12 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
86e138
 			vector_del_slot(mpp->paths, i);
86e138
 
86e138
 		/*
86e138
-		 * remove the map IF removing the last path
86e138
+		 * remove the map IF removing the last path. If
86e138
+		 * flush_map_nopaths succeeds, the path has been removed.
86e138
 		 */
86e138
-		if (VECTOR_SIZE(mpp->paths) == 0) {
86e138
-			char alias[WWID_SIZE];
86e138
-
86e138
-			/*
86e138
-			 * flush_map will fail if the device is open
86e138
-			 */
86e138
-			strlcpy(alias, mpp->alias, WWID_SIZE);
86e138
-			if (mpp->flush_on_last_del == FLUSH_ENABLED) {
86e138
-				condlog(2, "%s Last path deleted, disabling queueing", mpp->alias);
86e138
-				mpp->retry_tick = 0;
86e138
-				mpp->no_path_retry = NO_PATH_RETRY_FAIL;
86e138
-				mpp->disable_queueing = 1;
86e138
-				mpp->stat_map_failures++;
86e138
-				dm_queue_if_no_path(mpp->alias, 0);
86e138
-			}
86e138
-			if (!flush_map(mpp, vecs, 1)) {
86e138
-				condlog(2, "%s: removed map after"
86e138
-					" removing all paths",
86e138
-					alias);
86e138
-				/* flush_map() has freed the path */
86e138
-				goto out;
86e138
-			}
86e138
-			/*
86e138
-			 * Not an error, continue
86e138
-			 */
86e138
-		}
86e138
+		if (VECTOR_SIZE(mpp->paths) == 0 &&
86e138
+		    flush_map_nopaths(mpp, vecs))
86e138
+			goto out;
86e138
 
86e138
 		if (setup_map(mpp, &params, vecs)) {
86e138
 			condlog(0, "%s: failed to setup map for"