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

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