Blame SOURCES/0011-multipathd-don-t-fail-to-remove-path-once-the-map-is.patch

68b27c
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
68b27c
From: Benjamin Marzinski <bmarzins@redhat.com>
68b27c
Date: Tue, 11 May 2021 11:15:47 -0500
68b27c
Subject: [PATCH] multipathd: don't fail to remove path once the map is removed
68b27c
68b27c
In ev_remove_path(), if update_mpp_paths() fails, we delete the entire
68b27c
map. However, since update_mpp_paths() happens before we call
68b27c
set_path_removed(), pp->initialized isn't set to INIT_REMOVED, so
68b27c
remove_map_and_stop_waiter() doesn't remove the path when in removes the
68b27c
map.  But with the map removed, there's nothing to keep us from removing
68b27c
the path.
68b27c
68b27c
Call set_path_removed() before update_mpp_paths() to avoid the odd case
68b27c
of ev_remove_path() removing the map but not the path.
68b27c
68b27c
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
68b27c
---
68b27c
 libmultipath/structs_vec.c |  4 ++--
68b27c
 multipathd/main.c          | 13 ++++++++-----
68b27c
 2 files changed, 10 insertions(+), 7 deletions(-)
68b27c
68b27c
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
68b27c
index d242c06b..75390198 100644
68b27c
--- a/libmultipath/structs_vec.c
68b27c
+++ b/libmultipath/structs_vec.c
68b27c
@@ -45,8 +45,8 @@ int update_mpp_paths(struct multipath *mpp, vector pathvec)
68b27c
 
68b27c
 				/*
68b27c
 				 * Avoid adding removed paths to the map again
68b27c
-				 * when we reload it. Such paths may exist if
68b27c
-				 * domap fails in ev_remove_path().
68b27c
+				 * when we reload it. Such paths may exist in
68b27c
+				 * ev_remove_paths() or if it returns failure.
68b27c
 				 */
68b27c
 				pp1 = find_path_by_devt(pathvec, pp->dev_t);
68b27c
 				if (pp1 && pp->initialized != INIT_REMOVED &&
68b27c
diff --git a/multipathd/main.c b/multipathd/main.c
68b27c
index 102946bf..449ce384 100644
68b27c
--- a/multipathd/main.c
68b27c
+++ b/multipathd/main.c
68b27c
@@ -1199,6 +1199,13 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
68b27c
 	 * avoid referring to the map of an orphaned path
68b27c
 	 */
68b27c
 	if ((mpp = pp->mpp)) {
68b27c
+		/*
68b27c
+		 * Mark the path as removed. In case of success, we
68b27c
+		 * will delete it for good. Otherwise, it will be deleted
68b27c
+		 * later, unless all attempts to reload this map fail.
68b27c
+		 */
68b27c
+		set_path_removed(pp);
68b27c
+
68b27c
 		/*
68b27c
 		 * transform the mp->pg vector of vectors of paths
68b27c
 		 * into a mp->params string to feed the device-mapper
68b27c
@@ -1210,13 +1217,9 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
68b27c
 		}
68b27c
 
68b27c
 		/*
68b27c
-		 * Mark the path as removed. In case of success, we
68b27c
-		 * will delete it for good. Otherwise, it will be deleted
68b27c
-		 * later, unless all attempts to reload this map fail.
68b27c
-		 * Note: we have to explicitly remove pp from mpp->paths,
68b27c
+		 * we have to explicitly remove pp from mpp->paths,
68b27c
 		 * update_mpp_paths() doesn't do that.
68b27c
 		 */
68b27c
-		set_path_removed(pp);
68b27c
 		i = find_slot(mpp->paths, pp);
68b27c
 		if (i != -1)
68b27c
 			vector_del_slot(mpp->paths, i);