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

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