Blame SOURCES/0005-RH-add-mpathconf.patch

671555
---
671555
 libmultipath/config.c |    1 
671555
 multipath/Makefile    |    5 
671555
 multipath/main.c      |    4 
671555
 multipath/mpathconf   |  312 ++++++++++++++++++++++++++++++++++++++++++++++++++
671555
 multipath/mpathconf.8 |  103 ++++++++++++++++
671555
 5 files changed, 423 insertions(+), 2 deletions(-)
671555
671555
Index: multipath-tools-130222/libmultipath/config.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmultipath/config.c
671555
+++ multipath-tools-130222/libmultipath/config.c
671555
@@ -589,6 +589,7 @@ load_config (char * file)
671555
 		condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
671555
 		condlog(0, "A default multipath.conf file is located at");
671555
 		condlog(0, "/usr/share/doc/device-mapper-multipath-%d.%d.%d/multipath.conf", MULTIPATH_VERSION(VERSION_CODE));
671555
+		condlog(0, "You can run /sbin/mpathconf to create or modify /etc/multipath.conf");
671555
 		if (conf->blist_devnode == NULL) {
671555
 			conf->blist_devnode = vector_alloc();
671555
 			if (!conf->blist_devnode) {
671555
Index: multipath-tools-130222/multipath/Makefile
671555
===================================================================
671555
--- multipath-tools-130222.orig/multipath/Makefile
671555
+++ multipath-tools-130222/multipath/Makefile
671555
@@ -17,22 +17,27 @@ $(EXEC): $(OBJS)
671555
 	$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS)
671555
 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
671555
 	$(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
671555
+	$(GZIP) mpathconf.8 > mpathconf.8.gz
671555
 
671555
 install:
671555
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
671555
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
671555
+	$(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/
671555
 	$(INSTALL_PROGRAM) -d $(DESTDIR)/lib/udev/rules.d
671555
 	$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)/lib/udev/rules.d/62-multipath.rules
671555
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
671555
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
671555
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
671555
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir)
671555
+	$(INSTALL_PROGRAM) -m 644 mpathconf.8.gz $(DESTDIR)$(mandir)
671555
 
671555
 uninstall:
671555
 	rm $(DESTDIR)/lib/udev/rules.d/62-multipath.rules
671555
 	rm $(DESTDIR)$(bindir)/$(EXEC)
671555
+	rm $(DESTDIR)$(bindir)/mpathconf
671555
 	rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
671555
 	rm $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
671555
+	rm $(DESTDIR)$(mandir)/mpathconf.8.gz
671555
 
671555
 clean:
671555
 	rm -f core *.o $(EXEC) *.gz
671555
Index: multipath-tools-130222/multipath/main.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/multipath/main.c
671555
+++ multipath-tools-130222/multipath/main.c
671555
@@ -433,10 +433,10 @@ main (int argc, char *argv[])
671555
 		exit(1);
671555
 	}
671555
 
671555
-	if (dm_prereq())
671555
+	if (load_config(DEFAULT_CONFIGFILE))
671555
 		exit(1);
671555
 
671555
-	if (load_config(DEFAULT_CONFIGFILE))
671555
+	if (dm_prereq())
671555
 		exit(1);
671555
 
671555
 	while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:Brtq")) != EOF ) {
671555
Index: multipath-tools-130222/multipath/mpathconf
671555
===================================================================
671555
--- /dev/null
671555
+++ multipath-tools-130222/multipath/mpathconf
671555
@@ -0,0 +1,312 @@
671555
+#!/bin/sh
671555
+#
671555
+# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
671555
+#
671555
+# This file is part of the device-mapper-multipath package.
671555
+#
671555
+# This copyrighted material is made available to anyone wishing to use,
671555
+# modify, copy, or redistribute it subject to the terms and conditions
671555
+# of the GNU General Public License v.2.
671555
+#
671555
+# You should have received a copy of the GNU General Public License
671555
+# along with this program; if not, write to the Free Software Foundation,
671555
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
671555
+
671555
+#
671555
+# Simple editting of /etc/multipath.conf
671555
+# This program was largely ripped off from lvmconf
671555
+#
671555
+
671555
+unset ENABLE FIND FRIENDLY MODULE MULTIPATHD HAVE_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_DEFAULTS HAVE_FRIENDLY HAVE_MULTIPATHD HAVE_MODULE SHOW_STATUS CHANGED_CONFIG
671555
+
671555
+DEFAULT_CONFIGFILE="/usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf"
671555
+CONFIGFILE="/etc/multipath.conf"
671555
+MULTIPATHDIR="/etc/multipath"
671555
+TMPFILE=/etc/multipath/.multipath.conf.tmp
671555
+
671555
+function usage
671555
+{
671555
+	echo "usage: $0 <command>"
671555
+	echo ""
671555
+	echo "Commands:"
671555
+	echo "Enable: --enable "
671555
+	echo "Disable: --disable"
671555
+	echo "Set user_friendly_names (Default n): --user_friendly_names <y|n>"
671555
+	echo "Set find_multipaths (Default n): --find_multipaths <y|n>"
671555
+	echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
671555
+	echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
671555
+	echo ""
671555
+}
671555
+
671555
+function parse_args
671555
+{
671555
+	while [ -n "$1" ]; do
671555
+		case $1 in
671555
+			--enable)
671555
+				ENABLE=1
671555
+				shift
671555
+				;;
671555
+			--disable)
671555
+				ENABLE=0
671555
+				shift
671555
+				;;
671555
+			--user_friendly_names)
671555
+				if [ -n "$2" ]; then
671555
+					FRIENDLY=$2
671555
+					shift 2
671555
+				else
671555
+					usage
671555
+					exit 1
671555
+				fi
671555
+				;;
671555
+			--find_multipaths)
671555
+				if [ -n "$2" ]; then
671555
+					FIND=$2
671555
+					shift 2
671555
+				else
671555
+					usage
671555
+					exit 1
671555
+				fi
671555
+				;;
671555
+			--with_module)
671555
+				if [ -n "$2" ]; then
671555
+					MODULE=$2
671555
+					shift 2
671555
+				else
671555
+					usage
671555
+					exit 1
671555
+				fi
671555
+				;;
671555
+			--with_multipathd)
671555
+				if [ -n "$2" ]; then
671555
+					MULTIPATHD=$2
671555
+					shift 2
671555
+				else
671555
+					usage
671555
+					exit 1
671555
+				fi
671555
+				;;
671555
+			*)
671555
+				usage
671555
+				exit
671555
+		esac
671555
+	done
671555
+}
671555
+
671555
+function validate_args
671555
+{
671555
+	if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$MODULE" ]; then
671555
+		echo "ignoring extra parameters on disable"
671555
+		FRIENDLY=""
671555
+		FIND=""
671555
+		MODULE=""
671555
+	fi
671555
+	if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
671555
+		echo "--user_friendly_names must be either 'y' or 'n'"
671555
+		exit 1
671555
+	fi
671555
+	if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then
671555
+		echo "--find_multipaths must be either 'y' or 'n'"
671555
+		exit 1
671555
+	fi
671555
+	if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" ]; then
671555
+		SHOW_STATUS=1
671555
+	fi
671555
+	if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
671555
+		echo "--with_module must be either 'y' or 'n'"
671555
+		exit 1
671555
+	fi
671555
+	if [ -n "$MULTIPATHD" ] && [ "$MULTIPATHD" != "y" -a "$MULTIPATHD" != "n" ]; then
671555
+		echo "--with_multipathd must be either 'y' or 'n'"
671555
+		exit 1
671555
+	fi
671555
+}
671555
+
671555
+umask 0077
671555
+
671555
+parse_args "$@"
671555
+
671555
+validate_args
671555
+
671555
+if [ ! -d "$MULTIPATHDIR" ]; then
671555
+	echo "/etc/multipath/ does not exist. failing"
671555
+	exit 1
671555
+fi
671555
+
671555
+rm $TMPFILE 2> /dev/null
671555
+if [ -f "$CONFIGFILE" ]; then
671555
+	cp $CONFIGFILE $TMPFILE
671555
+elif [ -f "$DEFAULT_CONFIGFILE" ]; then
671555
+	cp $DEFAULT_CONFIGFILE $TMPFILE
671555
+else
671555
+	touch $TMPFILE
671555
+fi
671555
+
671555
+if grep -q "^blacklist[[:space:]]*{" $TMPFILE ; then
671555
+	HAVE_BLACKLIST=1
671555
+fi
671555
+
671555
+if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then
671555
+	HAVE_DEFAULTS=1
671555
+fi
671555
+
671555
+if [ -z "$MODULE" -o "$MODULE" = "y" ]; then
671555
+	if lsmod | grep -q "dm_multipath" ; then
671555
+		HAVE_MODULE=1
671555
+	else
671555
+		HAVE_MODULE=0
671555
+	fi
671555
+fi
671555
+
671555
+if [ "$MULTIPATHD" = "y" ]; then
671555
+	if service multipathd status > /dev/null ; then
671555
+		HAVE_MULTIPATHD=1
671555
+	else
671555
+		HAVE_MULTIPATHD=0
671555
+	fi
671555
+fi
671555
+
671555
+if [ "$HAVE_BLACKLIST" = "1" ]; then
671555
+	if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
671555
+		HAVE_DISABLE=1
671555
+	elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"" ; then
671555
+		HAVE_DISABLE=0
671555
+	fi
671555
+fi
671555
+
671555
+if [ "$HAVE_DEFAULTS" = "1" ]; then
671555
+	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then
671555
+		HAVE_FIND=1
671555
+	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then
671555
+		HAVE_FIND=0
671555
+	fi
671555
+	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
671555
+		HAVE_FRIENDLY=1
671555
+	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then
671555
+		HAVE_FRIENDLY=0
671555
+	fi
671555
+fi
671555
+
671555
+if [ -n "$SHOW_STATUS" ]; then
671555
+	if [ -z "$HAVE_DISABLE" -o "$HAVE_DISABLE" = 0 ]; then
671555
+		echo "multipath is enabled"
671555
+	else
671555
+		echo "multipath is disabled"
671555
+	fi
671555
+	if [ -z "$HAVE_FIND"  -o "$HAVE_FIND" = 0 ]; then
671555
+		echo "find_multipaths is disabled"
671555
+	else
671555
+		echo "find_multipaths is enabled"
671555
+	fi
671555
+	if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then
671555
+		echo "user_friendly_names is disabled"
671555
+	else
671555
+		echo "user_friendly_names is enabled"
671555
+	fi
671555
+	if [ -n "$HAVE_MODULE" ]; then
671555
+		if [ "$HAVE_MODULE" = 1 ]; then
671555
+			echo "dm_multipath module is loaded"
671555
+		else
671555
+			echo "dm_multipath module is not loaded"
671555
+		fi
671555
+	fi
671555
+	if [ -n "$HAVE_MULTIPATHD" ]; then
671555
+		service multipathd status
671555
+	fi
671555
+	exit 0
671555
+fi
671555
+
671555
+if [ -z "$HAVE_BLACKLIST" ]; then
671555
+	cat >> $TMPFILE <<- _EOF_
671555
+
671555
+blacklist {
671555
+}
671555
+_EOF_
671555
+fi
671555
+
671555
+if [ -z "$HAVE_DEFAULTS" ]; then
671555
+	cat >> $TMPFILE <<- _EOF_
671555
+
671555
+defaults {
671555
+}
671555
+_EOF_
671555
+fi
671555
+
671555
+if [ "$ENABLE" = 1 ]; then
671555
+	if [ "$HAVE_DISABLE" = 1 ]; then
671555
+		sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/#	devnode ".*"/' $TMPFILE
671555
+	fi
671555
+elif [ "$ENABLE" = 0 ]; then
671555
+	if [ -z "$HAVE_DISABLE" ]; then
671555
+		sed -i '/^blacklist[[:space:]]*{/ a\
671555
+	devnode "*"
671555
+' $TMPFILE
671555
+	elif [ "$HAVE_DISABLE" = 0 ]; then
671555
+		sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"/	devnode ".*"/' $TMPFILE
671555
+	fi
671555
+fi
671555
+
671555
+if [ "$FIND" = "n" ]; then
671555
+	if [ "$HAVE_FIND" = 1 ]; then
671555
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/	find_multipaths no/' $TMPFILE
671555
+		CHANGED_CONFIG=1
671555
+	fi
671555
+elif [ "$FIND" = "y" ]; then
671555
+	if [ -z "$HAVE_FIND" ]; then
671555
+		sed -i '/^defaults[[:space:]]*{/ a\
671555
+	find_multipaths yes
671555
+' $TMPFILE
671555
+		CHANGED_CONFIG=1
671555
+	elif [ "$HAVE_FIND" = 0 ]; then
671555
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/	find_multipaths yes/' $TMPFILE
671555
+		CHANGED_CONFIG=1
671555
+	fi
671555
+fi
671555
+
671555
+if [ "$FRIENDLY" = "n" ]; then
671555
+	if [ "$HAVE_FRIENDLY" = 1 ]; then
671555
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/	user_friendly_names no/' $TMPFILE
671555
+		CHANGED_CONFIG=1
671555
+	fi
671555
+elif [ "$FRIENDLY" = "y" ]; then
671555
+	if [ -z "$HAVE_FRIENDLY" ]; then
671555
+		sed -i '/^defaults[[:space:]]*{/ a\
671555
+	user_friendly_names yes
671555
+' $TMPFILE
671555
+		CHANGED_CONFIG=1
671555
+	elif [ "$HAVE_FRIENDLY" = 0 ]; then
671555
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/	user_friendly_names yes/' $TMPFILE
671555
+		CHANGED_CONFIG=1
671555
+	fi
671555
+fi
671555
+
671555
+if [ -f "$CONFIGFILE" ]; then
671555
+	cp $CONFIGFILE $CONFIGFILE.old
671555
+	if [ $? != 0 ]; then
671555
+		echo "failed to backup old config file, $CONFIGFILE not updated"
671555
+		exit 1
671555
+	fi
671555
+fi
671555
+
671555
+cp $TMPFILE $CONFIGFILE
671555
+if [ $? != 0 ]; then
671555
+	echo "failed to copy new config file into place, check $CONFIGFILE is still OK"
671555
+	exit 1
671555
+fi
671555
+
671555
+rm -f $TMPFILE
671555
+
671555
+if [ "$ENABLE" = 1 ]; then
671555
+	if [ "$HAVE_MODULE" = 0 ]; then
671555
+		modprobe dm_multipath
671555
+	fi
671555
+	if [ "$HAVE_MULTIPATHD" = 0 ]; then
671555
+		service multipathd start
671555
+	fi
671555
+elif [ "$ENABLE" = 0 ]; then
671555
+	if [ "$HAVE_MULTIPATHD" = 1 ]; then
671555
+		service multipathd stop
671555
+	fi
671555
+elif [ -n "$CHANGED_CONFIG" -a "$HAVE_MULTIPATHD" = 1 ]; then
671555
+	service multipathd reload
671555
+fi
671555
Index: multipath-tools-130222/multipath/mpathconf.8
671555
===================================================================
671555
--- /dev/null
671555
+++ multipath-tools-130222/multipath/mpathconf.8
671555
@@ -0,0 +1,103 @@
671555
+.TH MPATHCONF 8 "June 2010" "" "Linux Administrator's Manual"
671555
+.SH NAME
671555
+mpathconf - A tool for configuring device-mapper-multipath
671555
+.SH SYNOPSIS
671555
+.B mpathconf
671555
+.RB [\| commands \|]
671555
+.RB [\| options \|]
671555
+.SH DESCRIPTION
671555
+.B mpathconf
671555
+is a utility that creates or modifies
671555
+.B /etc/multipath.conf.
671555
+It can enable or disable multipathing and configure some common options.
671555
+.B mpathconf
671555
+can also load the
671555
+.B dm_multipath
671555
+module, start and stop the
671555
+.B multipathd
671555
+daemon, and configure the
671555
+.B multipathd
671555
+service to start automatically or not. If
671555
+.B mpathconf
671555
+is called with no commands, it will display the current configuration.
671555
+
671555
+The default options for mpathconf are
671555
+.B --with_module
671555
+The
671555
+.B --with_multipathd
671555
+option is not set by default.  Enabling multipathing will load the
671555
+.B dm_multipath
671555
+module but it will not immediately start it. This is so
671555
+that users can manually edit their config file if necessary, before starting
671555
+.B multipathd.
671555
+
671555
+If
671555
+.B /etc/multipath.conf
671555
+already exists, mpathconf will edit it. If it does not exist, mpathconf will
671555
+use
671555
+.B /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
671555
+as the starting file. This file has
671555
+.B user_friendly_names
671555
+set. If this file does not exist, mpathconf will create
671555
+.B /etc/multipath.conf
671555
+from scratch.  For most users, this means that
671555
+.B user_friendly_names
671555
+will be set by default, unless they use the
671555
+.B --user_friendly_names n
671555
+command.
671555
+.SH COMMANDS
671555
+.TP
671555
+.B --enable
671555
+Removes any line that blacklists all device nodes from the
671555
+.B /etc/multipath.conf
671555
+blacklist section.
671555
+.TP
671555
+.B --disable
671555
+Adds a line that blacklists all device nodes to the
671555
+.B /etc/multipath.conf
671555
+blacklist section. If no blacklist section exists, it will create one.
671555
+.TP
671555
+.B --user_friendly_name \fP { \fBy\fP | \fBn\fP }
671555
+If set to \fBy\fP, this adds the line
671555
+.B user_friendly_names yes
671555
+to the
671555
+.B /etc/multipath.conf
671555
+defaults section. If set to \fBn\fP, this removes the line, if present. This
671555
+command can be used along with any other command.
671555
+.TP
671555
+.B --find_multipaths\fP { \fBy\fP | \fBn\fP }
671555
+If set to \fBy\fP, this adds the line
671555
+.B find_multipaths yes
671555
+to the
671555
+.B /etc/multipath.conf
671555
+defaults section. If set to \fBn\fP, this removes the line, if present. This
671555
+command can be used aldong with any other command.
671555
+.SH OPTIONS
671555
+.TP
671555
+.B --with_module\fP { \fBy\fP | \fBn\fP }
671555
+If set to \fBy\fP, this runs
671555
+.B modprobe dm_multipath
671555
+to install the multipath modules. This option only works with the
671555
+.B --enable
671555
+command. This option is set to \fBy\fP by default.
671555
+.TP
671555
+.B --with_multipathd { \fBy\fP | \fBn\fP }
671555
+If set to \fBy\fP, this runs
671555
+.B service multipathd start
671555
+to start the multipathd daemon on \fB--enable\fP,
671555
+.B service multipathd stop
671555
+to start the multipathd daemon on \fB--disable\fP, and
671555
+.B service multipathd reload
671555
+to reconfigure multipathd on \fB--user_frindly_names\fP and
671555
+\fB--find_multipaths\fP.
671555
+This option is set to \fBn\fP by default.
671555
+.SH FILES
671555
+.BR /etc/multipath.conf
671555
+.SH "SEE ALSO"
671555
+.BR multipath.conf (5),
671555
+.BR modprobe (8),
671555
+.BR multipath (8),
671555
+.BR multipathd (8),
671555
+.BR service (8),
671555
+.SH AUTHOR
671555
+Benjamin Marzinski <bmarzins@redhat.com>