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

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