Blame SOURCES/0040-RH-add-support-to-mpathconf-for-setting-recheck_wwid.patch

da32ae
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
da32ae
From: Benjamin Marzinski <bmarzins@redhat.com>
da32ae
Date: Thu, 3 Feb 2022 13:26:18 -0600
da32ae
Subject: [PATCH] RH: add support to mpathconf for setting recheck_wwid
da32ae
da32ae
mpathconf now supports --recheck_wwid <y|n> for setthing the
da32ae
recheck_wwid option
da32ae
da32ae
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
da32ae
---
da32ae
 multipath/mpathconf   | 48 ++++++++++++++++++++++++++++++++++++++++---
da32ae
 multipath/mpathconf.8 |  9 ++++++++
da32ae
 2 files changed, 54 insertions(+), 3 deletions(-)
da32ae
da32ae
diff --git a/multipath/mpathconf b/multipath/mpathconf
da32ae
index 6e33fb99..319664b1 100644
da32ae
--- a/multipath/mpathconf
da32ae
+++ b/multipath/mpathconf
da32ae
@@ -17,7 +17,7 @@
da32ae
 # This program was largely ripped off from lvmconf
da32ae
 #
da32ae
 
da32ae
-unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE
da32ae
+unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE HAVE_RECHECK_WWID RECHECK_WWID
da32ae
 
da32ae
 DEFAULT_CONFIG="# device-mapper-multipath configuration file
da32ae
 
da32ae
@@ -52,6 +52,7 @@ function usage
da32ae
 	echo "Set find_multipaths (Default y): --find_multipaths <yes|no|strict|greedy|smart>"
da32ae
 	echo "Set default property blacklist (Default n): --property_blacklist <y|n>"
da32ae
 	echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign <y|n>"
da32ae
+	echo "Set recheck_wwid (Defaut n): --recheck_wwid <y|n>"
da32ae
 	echo "Add/Change/Remove option in defaults section: --option <option_name>:<value>"
da32ae
 	echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
da32ae
 	echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
da32ae
@@ -145,6 +146,15 @@ function parse_args
da32ae
 					exit 1
da32ae
 				fi
da32ae
 				;;
da32ae
+			--recheck_wwid)
da32ae
+				if [ -n "$2" ]; then
da32ae
+					RECHECK_WWID=$2
da32ae
+					shift 2
da32ae
+				else
da32ae
+					usage
da32ae
+					exit 1
da32ae
+				fi
da32ae
+				;;
da32ae
 			--find_multipaths)
da32ae
 				if [ -n "$2" ]; then
da32ae
 					FIND=$2
da32ae
@@ -223,7 +233,7 @@ function parse_args
da32ae
 
da32ae
 function validate_args
da32ae
 {
da32ae
-	if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" ]; then
da32ae
+	if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" -o -n "$RECHECK_WWID" ]; then
da32ae
 		echo "ignoring extra parameters on disable"
da32ae
 		FRIENDLY=""
da32ae
 		FIND=""
da32ae
@@ -232,11 +242,16 @@ function validate_args
da32ae
 		FOREIGN=""
da32ae
 		OPTION_NAME=""
da32ae
 		OPTION_VALUE=""
da32ae
+		RECHECK_WWID=""
da32ae
 	fi
da32ae
 	if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
da32ae
 		echo "--user_friendly_names must be either 'y' or 'n'"
da32ae
 		exit 1
da32ae
 	fi
da32ae
+	if [ -n "$RECHECK_WWID" ] && [ "$RECHECK_WWID" != "y" -a "$RECHECK_WWID" != "n" ]; then
da32ae
+		echo "--recheck_wwid must be either 'y' or 'n'"
da32ae
+		exit 1
da32ae
+	fi
da32ae
 	if [ "$FIND" = "y" ]; then
da32ae
 		FIND="yes"
da32ae
 	elif [ "$FIND" = "n" ]; then
da32ae
@@ -265,7 +280,7 @@ function validate_args
da32ae
 			OPTION_VALUE=\"$OPTION_VALUE\"
da32ae
 		fi
da32ae
 	fi
da32ae
-	if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" ]; then
da32ae
+	if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" -a -z "$RECHECK_WWID" ]; then
da32ae
 		SHOW_STATUS=1
da32ae
 	fi
da32ae
 	if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
da32ae
@@ -367,6 +382,11 @@ if [ "$HAVE_DEFAULTS" = "1" ]; then
da32ae
 	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(no\|0\)" ; then
da32ae
 		HAVE_FRIENDLY=0
da32ae
 	fi
da32ae
+	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(yes\|1\)" ; then
da32ae
+		HAVE_RECHECK_WWID=1
da32ae
+	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(no\|0\)" ; then
da32ae
+		HAVE_RECHECK_WWID=0
da32ae
+	fi
da32ae
 	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*enable_foreign" ; then
da32ae
 		HAVE_FOREIGN=0
da32ae
 	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]][[:space:]]*\"\.\*\"" ; then
da32ae
@@ -411,6 +431,11 @@ if [ -n "$SHOW_STATUS" ]; then
da32ae
 	else
da32ae
 		echo "user_friendly_names is enabled"
da32ae
 	fi
da32ae
+	if [ -z "$HAVE_RECHECK_WWID" -o "$HAVE_RECHECK_WWID" = 0 ]; then
da32ae
+		echo "recheck_wwid is disabled"
da32ae
+	else
da32ae
+		echo "recheck_wwid is enabled"
da32ae
+	fi
da32ae
 	if [ -z "$HAVE_PROPERTY" -o "$HAVE_PROPERTY" = 0 ]; then
da32ae
 		echo "default property blacklist is disabled"
da32ae
 	else
da32ae
@@ -527,6 +552,23 @@ elif [ "$FRIENDLY" = "y" ]; then
da32ae
 	fi
da32ae
 fi
da32ae
 
da32ae
+if [ "$RECHECK_WWID" = "n" ]; then
da32ae
+	if [ "$HAVE_RECHECK_WWID" = 1 ]; then
da32ae
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(yes\|1\)/	recheck_wwid no/' $TMPFILE
da32ae
+		CHANGED_CONFIG=1
da32ae
+	fi
da32ae
+elif [ "$RECHECK_WWID" = "y" ]; then
da32ae
+	if [ -z "$HAVE_RECHECK_WWID" ]; then
da32ae
+		sed -i '/^defaults[[:space:]]*{/ a\
da32ae
+	recheck_wwid yes
da32ae
+' $TMPFILE
da32ae
+		CHANGED_CONFIG=1
da32ae
+	elif [ "$HAVE_RECHECK_WWID" = 0 ]; then
da32ae
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(no\|0\)/	recheck_wwid yes/' $TMPFILE
da32ae
+		CHANGED_CONFIG=1
da32ae
+	fi
da32ae
+fi
da32ae
+
da32ae
 if [ "$PROPERTY" = "n" ]; then
da32ae
 	if [ "$HAVE_PROPERTY" = 1 ]; then
da32ae
 		sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/#	property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE
da32ae
diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8
da32ae
index 496383b7..9c2fb835 100644
da32ae
--- a/multipath/mpathconf.8
da32ae
+++ b/multipath/mpathconf.8
da32ae
@@ -77,6 +77,15 @@ to the
da32ae
 defaults section. If set to \fBn\fP, this removes the line, if present. This
da32ae
 command can be used along with any other command.
da32ae
 .TP
da32ae
+.B --recheck_wwid \fP { \fBy\fP | \fBn\fP }
da32ae
+If set to \fBy\fP, this adds the line
da32ae
+.B recheck_wwid yes
da32ae
+to the
da32ae
+.B /etc/multipath.conf
da32ae
+defaults section, or sets an existing line to \fByes\fP. If set to \fBn\fP, this
da32ae
+sets an existing \fBrecheck_wwid\fP line to \fBno\fP. This command can be used
da32ae
+along with any other command.
da32ae
+.TP
da32ae
 .B --find_multipaths\fP { \fByes\fP | \fBno\fP | \fBstrict\fP | \fBgreedy\fP | \fBsmart\fP }
da32ae
 If set to \fB<value>\fP, this adds the line
da32ae
 .B find_multipaths <value>