8c4232d3f9
Modify 0104-RHBZ-631009-deferred-remove.patch * add man page info Refresh 0112-RHBZ-1194917-add-config_dir-option.patch Refresh 0114-RHBZ-1196394-delayed-reintegration.patch Add 0118-UPBZ-1200738-update-eternus-config.patch * update default config Add 0119-RHBZ-1081397-save-alua-info.patch * make prioritizers save information between calls to speed them up. Add 0120-RHBZ-1043093-realloc-fix.patch * free old memory if realloc fails. Add 0121-RHBZ-1197234-rules-fix.patch * make sure kpartx runs after an DM_ACTIVATION event occurs. Add 0122-RHBZ-1212590-dont-use-var.patch * use /run instead of /var/run Add 0123-UPBZ-1166072-fix-path-offline.patch * Don't mark quiesce and transport-offline paths as offline Add 0124-RHBZ-1209275-retrigger-uevents.patch * Make multipathd retrigger uevents when paths haven't successfully had their udev_attribute environment variable set by udev and add "retrigger_ties" and "retrigger_delay" to control this Add 0125-RHBZ-1153832-kpartx-delete.patch * Delete all partition devices with -d (not just the ones in the partition table) Add 0126-RHBZ-1211383-alias-collision.patch * make multipathd use the old alias, if rename failed and add "new_bindings_in_boot" to determine if new bindings can be added to the bindings file in the initramfs Add 0127-RHBZ-1201030-use-blk-availability.patch * Make multipath use blk-availability.service Add 0128-RHBZ-1222123-mpathconf-allow.patch * Add mpathconf --allow for creating specialized config files. Add 0129-RHBZ-1241774-sun-partition-numbering.patch * Make kpartx correctly number sun partitions.
245 lines
6.8 KiB
Diff
245 lines
6.8 KiB
Diff
---
|
|
multipath/mpathconf | 135 +++++++++++++++++++++++++++++++++++++++++++++++-----
|
|
1 file changed, 124 insertions(+), 11 deletions(-)
|
|
|
|
Index: multipath-tools-130222/multipath/mpathconf
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/multipath/mpathconf
|
|
+++ multipath-tools-130222/multipath/mpathconf
|
|
@@ -1,4 +1,4 @@
|
|
-#!/bin/sh
|
|
+#!/bin/bash
|
|
#
|
|
# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
|
|
#
|
|
@@ -17,7 +17,7 @@
|
|
# This program was largely ripped off from lvmconf
|
|
#
|
|
|
|
-unset ENABLE FIND FRIENDLY MODULE MULTIPATHD HAVE_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_DEFAULTS HAVE_FRIENDLY HAVE_MULTIPATHD HAVE_MODULE SHOW_STATUS CHANGED_CONFIG
|
|
+unset ENABLE FIND FRIENDLY MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST
|
|
|
|
DEFAULT_CONFIG="# device-mapper-multipath configuration file
|
|
|
|
@@ -38,8 +38,10 @@ defaults {
|
|
}"
|
|
|
|
CONFIGFILE="/etc/multipath.conf"
|
|
+OUTPUTFILE="/etc/multipath.conf"
|
|
MULTIPATHDIR="/etc/multipath"
|
|
TMPFILE="/etc/multipath/.multipath.conf.tmp"
|
|
+WWIDS=0
|
|
|
|
function usage
|
|
{
|
|
@@ -48,13 +50,60 @@ function usage
|
|
echo "Commands:"
|
|
echo "Enable: --enable "
|
|
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 "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
|
|
echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
|
|
+ echo "select output file (Default /etc/multipath.conf): --outfile <FILE>"
|
|
echo ""
|
|
}
|
|
|
|
+function get_dm_deps
|
|
+{
|
|
+ shift 3
|
|
+ while [ -n "$1" -a -n "$2" ]; do
|
|
+ MAJOR=$(echo $1 | tr -d '(,')
|
|
+ MINOR=$(echo $2 | tr -d ')')
|
|
+ UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null`
|
|
+ if [ -n "$UUID" ] ; then
|
|
+ set_dm_wwid $UUID
|
|
+ fi
|
|
+ shift 2
|
|
+ done
|
|
+}
|
|
+
|
|
+function set_dm_wwid
|
|
+{
|
|
+ if [[ "$1" =~ ^part[[:digit:]]+-mpath- ]] ; then
|
|
+ WWID_LIST[$WWIDS]="${1##part*-mpath-}"
|
|
+ ((WWIDS++))
|
|
+ elif [[ "$1" =~ ^mpath- ]] ; then
|
|
+ WWID_LIST[$WWIDS]="${1##mpath-}"
|
|
+ ((WWIDS++))
|
|
+ else
|
|
+ get_dm_deps `dmsetup deps -u $1`
|
|
+ fi
|
|
+}
|
|
+
|
|
+function set_wwid
|
|
+{
|
|
+ UUID=""
|
|
+ if [[ "$1" =~ ^[[:digit:]]+:[[:digit:]]+$ ]] ; then
|
|
+ MAJOR=${1%%:*}
|
|
+ MINOR=${1##*:}
|
|
+ UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null`
|
|
+ else
|
|
+ UUID=`dmsetup info -c --noheadings -o uuid $1 2> /dev/null`
|
|
+ fi
|
|
+ if [ -n "$UUID" ] ; then
|
|
+ set_dm_wwid $UUID
|
|
+ else
|
|
+ WWID_LIST[$WWIDS]="$1"
|
|
+ ((WWIDS++))
|
|
+ fi
|
|
+}
|
|
+
|
|
function parse_args
|
|
{
|
|
while [ -n "$1" ]; do
|
|
@@ -67,6 +116,16 @@ function parse_args
|
|
ENABLE=0
|
|
shift
|
|
;;
|
|
+ --allow)
|
|
+ ENABLE=2
|
|
+ if [ -n "$2" ]; then
|
|
+ set_wwid $2
|
|
+ shift 2
|
|
+ else
|
|
+ usage
|
|
+ exit 1
|
|
+ fi
|
|
+ ;;
|
|
--user_friendly_names)
|
|
if [ -n "$2" ]; then
|
|
FRIENDLY=$2
|
|
@@ -103,6 +162,16 @@ function parse_args
|
|
exit 1
|
|
fi
|
|
;;
|
|
+ --outfile)
|
|
+ if [ -n "$2" ]; then
|
|
+ OUTPUTFILE=$2
|
|
+ HAVE_OUTFILE=1
|
|
+ shift 2
|
|
+ else
|
|
+ usage
|
|
+ exit 1
|
|
+ fi
|
|
+ ;;
|
|
*)
|
|
usage
|
|
exit
|
|
@@ -137,6 +206,22 @@ function validate_args
|
|
echo "--with_multipathd must be either 'y' or 'n'"
|
|
exit 1
|
|
fi
|
|
+ if [ "$ENABLE" = 2 -a -z "$HAVE_OUTFILE" ]; then
|
|
+ echo "Because --allow makes changes that cannot be automatically reversed,"
|
|
+ echo "you must set --outfile when you set --allow"
|
|
+ exit 1
|
|
+ fi
|
|
+}
|
|
+
|
|
+function add_blacklist_exceptions
|
|
+{
|
|
+ echo "blacklist_exceptions {" >> $TMPFILE
|
|
+ INDEX=0
|
|
+ while [ "$INDEX" -lt "$WWIDS" ] ; do
|
|
+ echo " wwid \"${WWID_LIST[$INDEX]}\"" >> $TMPFILE
|
|
+ ((INDEX++))
|
|
+ done
|
|
+ echo "}" >> $TMPFILE
|
|
}
|
|
|
|
umask 0077
|
|
@@ -160,6 +245,10 @@ if grep -q "^blacklist[[:space:]]*{" $TM
|
|
HAVE_BLACKLIST=1
|
|
fi
|
|
|
|
+if grep -q "^blacklist_exceptions[[:space:]]*{" $TMPFILE ; then
|
|
+ HAVE_EXCEPTIONS=1
|
|
+fi
|
|
+
|
|
if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then
|
|
HAVE_DEFAULTS=1
|
|
fi
|
|
@@ -183,11 +272,19 @@ fi
|
|
if [ "$HAVE_BLACKLIST" = "1" ]; then
|
|
if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
|
|
HAVE_DISABLE=1
|
|
- elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"" ; then
|
|
+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"" ; then
|
|
HAVE_DISABLE=0
|
|
fi
|
|
fi
|
|
|
|
+if [ "$HAVE_BLACKLIST" = "1" ]; then
|
|
+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*wwid \"\.\?\*\"" ; then
|
|
+ HAVE_WWID_DISABLE=1
|
|
+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"" ; then
|
|
+ HAVE_WWID_DISABLE=0
|
|
+ fi
|
|
+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
|
|
@@ -255,17 +352,33 @@ defaults {
|
|
_EOF_
|
|
fi
|
|
|
|
-if [ "$ENABLE" = 1 ]; then
|
|
+if [ "$ENABLE" = 2 ]; then
|
|
+ if [ "$HAVE_DISABLE" = 1 ]; then
|
|
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
+ fi
|
|
+ if [ -z "$HAVE_WWID_DISABLE" ]; then
|
|
+ sed -i '/^blacklist[[:space:]]*{/ a\
|
|
+ wwid ".*"
|
|
+' $TMPFILE
|
|
+ elif [ "$HAVE_WWID_DISABLE" = 0 ]; then
|
|
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"/ wwid ".*"/' $TMPFILE
|
|
+ fi
|
|
+ if [ "$HAVE_EXCEPTIONS" = 1 ]; then
|
|
+ sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/d' $TMPFILE
|
|
+ fi
|
|
+ echo $HAVE_WWID_DISABLE
|
|
+ add_blacklist_exceptions
|
|
+elif [ "$ENABLE" = 1 ]; then
|
|
if [ "$HAVE_DISABLE" = 1 ]; then
|
|
sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
fi
|
|
elif [ "$ENABLE" = 0 ]; then
|
|
if [ -z "$HAVE_DISABLE" ]; then
|
|
sed -i '/^blacklist[[:space:]]*{/ a\
|
|
- devnode "*"
|
|
+ devnode ".*"
|
|
' $TMPFILE
|
|
elif [ "$HAVE_DISABLE" = 0 ]; then
|
|
- sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE
|
|
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE
|
|
fi
|
|
fi
|
|
|
|
@@ -303,17 +416,17 @@ elif [ "$FRIENDLY" = "y" ]; then
|
|
fi
|
|
fi
|
|
|
|
-if [ -f "$CONFIGFILE" ]; then
|
|
- cp $CONFIGFILE $CONFIGFILE.old
|
|
+if [ -f "$OUTPUTFILE" ]; then
|
|
+ cp $OUTPUTFILE $OUTPUTFILE.old
|
|
if [ $? != 0 ]; then
|
|
- echo "failed to backup old config file, $CONFIGFILE not updated"
|
|
+ echo "failed to backup old config file, $OUTPUTFILE not updated"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
-cp $TMPFILE $CONFIGFILE
|
|
+cp $TMPFILE $OUTPUTFILE
|
|
if [ $? != 0 ]; then
|
|
- echo "failed to copy new config file into place, check $CONFIGFILE is still OK"
|
|
+ echo "failed to copy new config file into place, check $OUTPUTFILE is still OK"
|
|
exit 1
|
|
fi
|
|
|