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

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