Blame SOURCES/0083-multipath.rules-fix-smart-bug-with-failed-valid-path.patch

86e138
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
86e138
From: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Date: Tue, 7 Feb 2023 15:39:26 -0600
86e138
Subject: [PATCH] multipath.rules: fix "smart" bug with failed valid path check
86e138
86e138
If "multipath -u" fails, udev doesn't import any values from the
86e138
program. This means that multipath.rules will continue to use the values
86e138
for DM_MULTIPATH_DEVICE_PATH and FIND_MULTIPATHS_WAIT_UNTIL that it has
86e138
already imported from the database. This is the correct thing to do for
86e138
every case except the MAYBE case for "find_multipaths smart". In that
86e138
case, DM_MULTIPATH_DEVICE_PATH will be set to 1, and the rules will
86e138
assume that the device has been definitively claimed.
86e138
86e138
In this case, we know that the device shouldn't have been claimed
86e138
before, but we don't know if it should be claimed now, or if we have hit
86e138
the timeout and it should be released, since we didn't get any
86e138
information from multipath. The safest thing to do is assume that this
86e138
was the timeout, and the device shouldn't be claimed. The only time when
86e138
this could be the wrong answer is when we first see a new multipath
86e138
device, and it could only cause problems if there is metadata on the
86e138
device that will cause it to get autoassembled by something else, before
86e138
multipathd can autoassemble it. If we assume that it is a multipath
86e138
device, or we assume that this wasn't actually the timeout uevent, we
86e138
can keep a necessary device from getting released to the reset of the
86e138
system.
86e138
86e138
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
86e138
---
86e138
 multipath/multipath.rules.in | 22 ++++++++++++++++------
86e138
 1 file changed, 16 insertions(+), 6 deletions(-)
86e138
86e138
diff --git a/multipath/multipath.rules.in b/multipath/multipath.rules.in
86e138
index 5c4447a2..70b69a06 100644
86e138
--- a/multipath/multipath.rules.in
86e138
+++ b/multipath/multipath.rules.in
86e138
@@ -32,7 +32,8 @@ IMPORT{db}="DM_MULTIPATH_DEVICE_PATH"
86e138
 
86e138
 # multipath -u sets DM_MULTIPATH_DEVICE_PATH and,
86e138
 # if "find_multipaths smart", also FIND_MULTIPATHS_WAIT_UNTIL.
86e138
-IMPORT{program}="$env{MPATH_SBIN_PATH}/multipath -u %k"
86e138
+IMPORT{program}=="$env{MPATH_SBIN_PATH}/multipath -u %k", \
86e138
+	ENV{.MPATH_CHECK_PASSED}="1"
86e138
 
86e138
 # case 1: this is definitely multipath
86e138
 ENV{DM_MULTIPATH_DEVICE_PATH}=="1", \
86e138
@@ -83,10 +84,19 @@ LABEL="stop_wait"
86e138
 # If timeout hasn't expired but we're not in "maybe" state any more, stop timer
86e138
 # Do this only once, and only if the timer has been started before
86e138
 IMPORT{db}="FIND_MULTIPATHS_WAIT_CANCELLED"
86e138
-ENV{FIND_MULTIPATHS_WAIT_CANCELLED}!="?*", \
86e138
-	ENV{FIND_MULTIPATHS_WAIT_UNTIL}=="?*", \
86e138
-	ENV{FIND_MULTIPATHS_WAIT_UNTIL}!="0", \
86e138
-	ENV{FIND_MULTIPATHS_WAIT_CANCELLED}="1", \
86e138
-	RUN+="/usr/bin/systemctl stop cancel-multipath-wait-$kernel.timer"
86e138
+ENV{FIND_MULTIPATHS_WAIT_CANCELLED}=="?*", GOTO="end_mpath"
86e138
+ENV{FIND_MULTIPATHS_WAIT_UNTIL}!="?*", GOTO="end_mpath"
86e138
+ENV{FIND_MULTIPATHS_WAIT_UNTIL}=="0", GOTO="end_mpath"
86e138
+
86e138
+ENV{FIND_MULTIPATHS_WAIT_CANCELLED}="1"
86e138
+RUN+="/usr/bin/systemctl stop cancel-multipath-wait-$kernel.timer"
86e138
+
86e138
+# If "multipath -u" failed, no values are imported from the program,
86e138
+# and we are still using the values for DM_MULTIPATH_DEVICE_PATH and
86e138
+# FIND_MULTIPATHS_WAIT_UNTIL that were imported from the database.
86e138
+# If we are in "smart" mode, we need to give up on the path now,
86e138
+# since this may have been the timeout event. Without the imports
86e138
+# from "multipath -u", we can't tell.
86e138
+ENV{.MPATH_CHECK_PASSED}!="?*", ENV{DM_MULTIPATH_DEVICE_PATH}="0"
86e138
 
86e138
 LABEL="end_mpath"