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

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