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

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