device-mapper-multipath/SOURCES/0061-RH-fix-find_multipaths...

135 lines
5.2 KiB
Diff

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