Blame SOURCES/0061-RH-fix-find_multipaths-in-mpathconf.patch

b7337d
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b7337d
From: Benjamin Marzinski <bmarzins@redhat.com>
b7337d
Date: Wed, 10 Feb 2021 15:42:42 -0600
b7337d
Subject: [PATCH] RH: fix find_multipaths in mpathconf
b7337d
b7337d
mpathconf wasn't correctly dealing with the new rhel-8 values for
b7337d
find_multipaths
b7337d
b7337d
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
b7337d
---
b7337d
 multipath/mpathconf   | 38 +++++++++++++++++++-------------------
b7337d
 multipath/mpathconf.8 | 14 +++++++-------
b7337d
 2 files changed, 26 insertions(+), 26 deletions(-)
b7337d
b7337d
diff --git a/multipath/mpathconf b/multipath/mpathconf
b7337d
index f34003c9..2f4f3eaf 100644
b7337d
--- a/multipath/mpathconf
b7337d
+++ b/multipath/mpathconf
b7337d
@@ -54,7 +54,7 @@ function usage
b7337d
 	echo "Disable: --disable"
b7337d
 	echo "Only allow certain wwids (instead of enable): --allow <WWID>"
b7337d
 	echo "Set user_friendly_names (Default y): --user_friendly_names <y|n>"
b7337d
-	echo "Set find_multipaths (Default y): --find_multipaths <y|n>"
b7337d
+	echo "Set find_multipaths (Default y): --find_multipaths <yes|no|strict|greedy|smart>"
b7337d
 	echo "Set default property blacklist (Default y): --property_blacklist <y|n>"
b7337d
 	echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign <y|n>"
b7337d
 	echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
b7337d
@@ -224,8 +224,12 @@ function validate_args
b7337d
 		echo "--user_friendly_names must be either 'y' or 'n'"
b7337d
 		exit 1
b7337d
 	fi
b7337d
-	if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then
b7337d
-		echo "--find_multipaths must be either 'y' or 'n'"
b7337d
+	if [ "$FIND" = "y" ]; then
b7337d
+		FIND="yes"
b7337d
+	elif [ "$FIND" = "n" ]; then
b7337d
+		FIND="no"
b7337d
+	elif [ -n "$FIND" ] && [ "$FIND" != "yes" -a "$FIND" != "no" -a "$FIND" != "strict" -a "$FIND" != "greedy" -a "$FIND" != "smart" ]; then
b7337d
+		echo "--find_multipaths must be one of 'yes' 'no' 'strict' 'greedy' or 'smart'"
b7337d
 		exit 1
b7337d
 	fi
b7337d
 	if [ -n "$PROPERTY" ] && [ "$PROPERTY" != "y" -a "$PROPERTY" != "n" ]; then
b7337d
@@ -327,10 +331,11 @@ if [ "$HAVE_BLACKLIST" = "1" ]; then
b7337d
 fi
b7337d
 
b7337d
 if [ "$HAVE_DEFAULTS" = "1" ]; then
b7337d
-	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then
b7337d
-		HAVE_FIND=1
b7337d
-	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then
b7337d
-		HAVE_FIND=0
b7337d
+	HAVE_FIND=`sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | sed -n 's/^[[:blank:]]*find_multipaths[[:blank:]]*\([^[:blank:]]*\).*$/\1/p' | sed -n 1p`
b7337d
+	if [ "$HAVE_FIND" = "1" ]; then
b7337d
+		HAVE_FIND="yes"
b7337d
+	elif [ "$HAVE_FIND" = "0" ]; then
b7337d
+		HAVE_FIND="no"
b7337d
 	fi
b7337d
 	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
b7337d
 		HAVE_FRIENDLY=1
b7337d
@@ -360,10 +365,10 @@ if [ -n "$SHOW_STATUS" ]; then
b7337d
 	else
b7337d
 		echo "multipath is disabled"
b7337d
 	fi
b7337d
-	if [ -z "$HAVE_FIND"  -o "$HAVE_FIND" = 0 ]; then
b7337d
-		echo "find_multipaths is disabled"
b7337d
+	if [ -z "$HAVE_FIND" ]; then
b7337d
+		echo "find_multipaths is no"
b7337d
 	else
b7337d
-		echo "find_multipaths is enabled"
b7337d
+		echo "find_multipaths is $HAVE_FIND"
b7337d
 	fi
b7337d
 	if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then
b7337d
 		echo "user_friendly_names is disabled"
b7337d
@@ -455,19 +460,14 @@ elif [ "$ENABLE" = 0 ]; then
b7337d
 	fi
b7337d
 fi
b7337d
 
b7337d
-if [ "$FIND" = "n" ]; then
b7337d
-	if [ "$HAVE_FIND" = 1 ]; then
b7337d
-		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/	find_multipaths no/' $TMPFILE
b7337d
-		CHANGED_CONFIG=1
b7337d
-	fi
b7337d
-elif [ "$FIND" = "y" ]; then
b7337d
+if [ -n "$FIND" ]; then
b7337d
 	if [ -z "$HAVE_FIND" ]; then
b7337d
 		sed -i '/^defaults[[:space:]]*{/ a\
b7337d
-	find_multipaths yes
b7337d
+	find_multipaths '"$FIND"'
b7337d
 ' $TMPFILE
b7337d
 		CHANGED_CONFIG=1
b7337d
-	elif [ "$HAVE_FIND" = 0 ]; then
b7337d
-		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/	find_multipaths yes/' $TMPFILE
b7337d
+	elif [ "$FIND" != "$HAVE_FIND" ]; then
b7337d
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:blank:]]*find_multipaths[[:blank:]]*[^[:blank:]]*/	find_multipaths '"$FIND"'/' $TMPFILE
b7337d
 		CHANGED_CONFIG=1
b7337d
 	fi
b7337d
 fi
b7337d
diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8
b7337d
index b82961d6..83515eb4 100644
b7337d
--- a/multipath/mpathconf.8
b7337d
+++ b/multipath/mpathconf.8
b7337d
@@ -38,9 +38,9 @@ If
b7337d
 already exists, mpathconf will edit it. If it does not exist, mpathconf will
b7337d
 create a default file with
b7337d
 .B user_friendly_names
b7337d
-and
b7337d
+set and
b7337d
 .B find_multipaths
b7337d
-set. To disable these, use the
b7337d
+set to \fByes\fP. To disable these, use the
b7337d
 .B --user_friendly_names n
b7337d
 and
b7337d
 .B --find_multipaths n
b7337d
@@ -77,13 +77,13 @@ to the
b7337d
 defaults section. If set to \fBn\fP, this removes the line, if present. This
b7337d
 command can be used along with any other command.
b7337d
 .TP
b7337d
-.B --find_multipaths\fP { \fBy\fP | \fBn\fP }
b7337d
-If set to \fBy\fP, this adds the line
b7337d
-.B find_multipaths yes
b7337d
+.B --find_multipaths\fP { \fByes\fP | \fBno\fP | \fBstrict\fP | \fBgreedy\fP | \fBsmart\fP }
b7337d
+If set to \fB<value>\fP, this adds the line
b7337d
+.B find_multipaths <value>
b7337d
 to the
b7337d
 .B /etc/multipath.conf
b7337d
-defaults section. If set to \fBn\fP, this removes the line, if present. This
b7337d
-command can be used along with any other command.
b7337d
+defaults section. This command can be used along with any other command.
b7337d
+\fBy\fP and \fBn\fP can be used instead of \fByes\fP and \fBno\fP.
b7337d
 .TP
b7337d
 .B --property_blacklist \fP { \fBy\fP | \fBn\fP }
b7337d
 If set to \fBy\fP, this adds the line
b7337d
-- 
b7337d
2.17.2
b7337d