Blame SOURCES/0076-multipathd-don-t-access-path-if-it-was-deleted.patch

3978af
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
3978af
From: Benjamin Marzinski <bmarzins@redhat.com>
3978af
Date: Fri, 23 Jul 2021 14:10:06 -0500
3978af
Subject: [PATCH] multipathd: don't access path if it was deleted
3978af
3978af
ev_remove_path() could fail and still delete the path. This could cause
3978af
problems for handle_path_wwid_change(), which expected that a failure
3978af
meant that the path still existed. ev_remove_path now returns a
3978af
different error code for failure to reload the multipath device, so that
3978af
it can be differentiated from cases where the path was no removed.
3978af
3978af
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3978af
---
3978af
 multipathd/main.c | 11 +++++++----
3978af
 1 file changed, 7 insertions(+), 4 deletions(-)
3978af
3978af
diff --git a/multipathd/main.c b/multipathd/main.c
3978af
index e6c19ab2..823b53a2 100644
3978af
--- a/multipathd/main.c
3978af
+++ b/multipathd/main.c
3978af
@@ -86,6 +86,9 @@
3978af
 #define FILE_NAME_SIZE 256
3978af
 #define CMDSIZE 160
3978af
 
3978af
+#define PATH_REMOVE_FAILED 1
3978af
+#define MAP_RELOAD_FAILED 2
3978af
+
3978af
 #define LOG_MSG(lvl, verb, pp)					\
3978af
 do {								\
3978af
 	if (pp->mpp && checker_selected(&pp->checker) &&	\
3978af
@@ -840,7 +843,7 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs)
3978af
 		return;
3978af
 
3978af
 	udd = udev_device_ref(pp->udev);
3978af
-	if (ev_remove_path(pp, vecs, 1) != 0 && pp->mpp) {
3978af
+	if (ev_remove_path(pp, vecs, 1) == PATH_REMOVE_FAILED && pp->mpp) {
3978af
 		pp->dmstate = PSTATE_FAILED;
3978af
 		dm_fail_path(pp->mpp->alias, pp->dev_t);
3978af
 	}
3978af
@@ -1226,13 +1229,13 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
3978af
 			condlog(0, "%s: failed in domap for "
3978af
 				"removal of path %s",
3978af
 				mpp->alias, pp->dev);
3978af
-			retval = 1;
3978af
+			retval = MAP_RELOAD_FAILED;
3978af
 		} else {
3978af
 			/*
3978af
 			 * update our state from kernel
3978af
 			 */
3978af
 			if (setup_multipath(vecs, mpp))
3978af
-				return 1;
3978af
+				return PATH_REMOVE_FAILED;
3978af
 			sync_map_state(mpp);
3978af
 
3978af
 			condlog(2, "%s [%s]: path removed from map %s",
3978af
@@ -1250,7 +1253,7 @@ out:
3978af
 
3978af
 fail:
3978af
 	remove_map_and_stop_waiter(mpp, vecs);
3978af
-	return 1;
3978af
+	return PATH_REMOVE_FAILED;
3978af
 }
3978af
 
3978af
 static int