Hello community,
here is the log from the commit of package s390-tools for openSUSE:Factory checked in at 2017-11-03 16:21:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/s390-tools (Old)
and /work/SRC/openSUSE:Factory/.s390-tools.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "s390-tools"
Fri Nov 3 16:21:40 2017 rev:11 rq:537235 version:2.1.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/s390-tools/s390-tools.changes 2017-10-25 17:44:30.787886244 +0200
+++ /work/SRC/openSUSE:Factory/.s390-tools.new/s390-tools.changes 2017-11-03 16:21:47.842877303 +0100
@@ -1,0 +2,8 @@
+Wed Oct 25 17:21:30 UTC 2017 - mpost@suse.com
+
+- Modified s390-tools-sles15-Format-devices-in-parallel.patch to
+ reset the rc variable before using it again (bsc#1063393).
+- Reverted the changes to the *_configure scripts until
+ bsc#1064791 is fixed.
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ctc_configure ++++++
--- /var/tmp/diff_new_pack.qwTXCe/_old 2017-11-03 16:21:49.082832175 +0100
+++ /var/tmp/diff_new_pack.qwTXCe/_new 2017-11-03 16:21:49.086832029 +0100
@@ -2,127 +2,316 @@
#
# ctc_configure
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
-#
-# Configures a CTC device by calling the IBM-provided chzdev command.
-# Whereas this script used to validate the parameters provided to it,
-# we now rely on chzdev to do that instead. The script is intended only
-# as a "translation layer" to provide backward compatability for older
-# scripts and tools that invoke it.
+# Configures a CTC device
#
# Usage:
# ctc_configure <read channel> <write channel> <online> [<protocol>]
#
# read/write channel = x.y.ssss where
-# x is always 0 until IBM creates something that
-# uses that number
-# y is the logical channel subsystem (lcss) number.
-# Most often this is 0, but it could be non-zero
-# ssss is the four digit subchannel address of the
-# device, in hexidecimal, with leading zeros.
+# x is always 0 until IBM creates something that uses that number
+# y is the logical channel subsystem (lcss) number. Most often this is 0, but it could be non-zero
+# ssss is the four digit subchannel address of the device, in hexidecimal, with leading zeros.
# online = 0 to take the device offline
# 1 to bring the device online
-# protocol = 0 Compatibility with peers other than OS/390®, or z/OS, for
-# example, a z/VM TCP service machine. This is the default.
+# protocol = 0 Compatibility with peers other than OS/390®, or z/OS, for example, a z/VM TCP service machine. This is the default.
# 1 Enhanced package checking for Linux peers.
# 3 For compatibility with OS/390 or z/OS peers.
-# 4 For MPC connections to VTAM on traditional mainframe
-# operating systems.
+# 4 For MPC connections to VTAM on traditional mainframe operating systems.
#
# Return values:
-# Return codes are determined by the chzdev command.
+# 1 sysfs not mounted
+# 2 Invalid status for <online>
+# 3 No device found for read-channel
+# 4 No device found for write-channel
+# 5 Invalid device type
+# 6 Device type mismatch
+# 7 Could not load module
+# 8 CCW devices grouped different devices
+# 9 Could not group devices
+# 10 Could not set device online
+# 11 Could not set device offline
#
+if [ "${DEBUG}" != "yes" ]; then
+ DEBUG="no"
+fi
+
+DATUM=$(date)
+
+add_channel_for_cio() {
+ echo "$* # $DATUM" >> /boot/zipl/active_devices.txt
+}
+
+remove_channel_for_cio() {
+ [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^$1/d" /boot/zipl/active_devices.txt
+}
+
mesg () {
echo "$@"
}
debug_mesg () {
- case "${DEBUG}" in
- yes) mesg "$@" ;;
- *) ;;
+ case "$DEBUG" in
+ yes) mesg "$@" ;;
+ *) ;;
esac
}
-add_cio_channel() {
- echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
-}
-
-remove_cio_channel() {
- [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
-}
+# Get the mount point for sysfs
+while read MNTPT MNTDIR MNTSYS MNTTYPE; do
+ if test "$MNTSYS" = "sysfs"; then
+ SYSFS="$MNTDIR"
+ break;
+ fi
+done ${_ccw_drivers}/ctcm/unbind
+ fi
+ if [ ! -e "${_ccw_drivers}/lcs/${i}" ] ; then
+ echo $i > ${_ccw_drivers}/ctcm/bind
+ fi
+ else
+ if [ -e "${_ccw_drivers}/lcs/${i}" ] ; then
+ echo $i > ${_ccw_drivers}/lcs/unbind
+ fi
+ if [ ! -e "${_ccw_drivers}/ctcm/${i}" ] ; then
+ echo $i > ${_ccw_drivers}/ctcm/bind
+ fi
+ fi
+ done
+
+debug_mesg "Group is ${_ccw_groupdir}/drivers/${CCW_CHAN_GROUP}/group"
+if [ -z "$_ccw_status_dir" ] ; then
+ echo "$CTC_READ_CHAN,$CTC_WRITE_CHAN" > ${_ccw_groupdir}/drivers/${CCW_CHAN_GROUP}/group
+ if [ -e ${_ccw_dir}/${CTC_READ_CHAN}/group_device ] ; then
+ _ccw_status_dir=$(cd -P ${_ccw_dir}/${CTC_READ_CHAN}/group_device; echo $PWD)
+ fi
fi
-if [ "${ON_OFF}" == 0 ]; then
- debug_mesg "chzdev -d ${DEV_TYPE} ${CTC_READ_CHAN}"
- chzdev -d ${DEV_TYPE} ${CTC_READ_CHAN}
-elif [ "${ON_OFF}" == 1 ]; then
- debug_mesg "chzdev -e ${DEV_TYPE} ${CTC_READ_CHAN} ${PARM_LIST}"
- chzdev -e ${DEV_TYPE} ${CTC_READ_CHAN} ${PARM_LIST}
-else mesg "You must specify a 0 or a 1 for the online/offline attribute."
- usage
- exit 1
+if [ -z "$_ccw_status_dir" -o ! -e "$_ccw_status_dir" ] ; then
+ mesg "Could not group $CCW_CHAN_GROUP devices $CTC_READ_CHAN/$CTC_WRITE_CHAN"
+ exit 9
fi
-RC=${?}
-if [ ${RC} -ne 0 ]; then
- exit ${RC}
+CCW_CHAN_ID=${_ccw_status_dir##*/}
+
+read _ccw_dev_status < $_ccw_status_dir/online
+
+if [ "$ONLINE" -eq 1 ]; then
+ # Check whether we need to do something
+ if [ "$_ccw_dev_status" -eq 0 ]; then
+ if [ "$CTC_MODE" -gt 0 -a "$CCW_CHAN_GROUP" != "lcs" ]; then
+ echo $CTC_MODE > $_ccw_status_dir/protocol
+ fi
+ # Set the device online
+ debug_mesg "Setting device online"
+ echo "1" > $_ccw_status_dir/online
+ # Re-read device status
+ read _ccw_dev_status < $_ccw_status_dir/online
+ if [ "$_ccw_dev_status" -eq 0 ]; then
+ mesg "Could not set device ${CCW_CHAN_ID} online"
+ exit 10
+ fi
+ else
+ debug_mesg "Device ${CCW_CHAN_ID} is already online"
+ fi
+else
+ if [ "$_ccw_dev_status" -eq 1 ]; then
+ # Set the device offline
+ debug_mesg "Setting device offline"
+ echo "$ONLINE" > $_ccw_status_dir/online
+
+ # Re-read to check whether we have succeeded
+ _ccw_dev_status=$(cat $_ccw_status_dir/online)
+ if [ "$_ccw_dev_status" -ne "$ONLINE" ]; then
+ mesg "Could not set device ${CCW_CHAN_ID} offline"
+ exit 11
+ fi
+ else
+ debug_mesg "Device ${CCW_CHAN_ID} is already offline"
+ fi
+ # Always reset CTC Protocol
+ if [ "$CCW_CHAN_GROUP" != "lcs" ]; then
+ echo 0 > $_ccw_status_dir/protocol
+ fi
fi
-if [ ${ON_OFF} == 1 ]; then
- add_cio_channel "${CTC_READ_CHAN},${CTC_WRITE_CHAN}"
-else remove_cio_channel "${CTC_READ_CHAN}"
- remove_cio_channel "${CTC_WRITE_CHAN}"
+RULES_DIR=/etc/udev/rules.d
+RULES_FILE=51-${CCW_CHAN_GROUP}-${CCW_CHAN_ID}.rules
+
+if [ -d "$RULES_DIR" ]; then
+ if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
+ rm -f ${RULES_DIR}/${RULES_FILE}
+ fi
+ remove_channel_for_cio "$CTC_READ_CHAN"
+ remove_channel_for_cio "$CTC_WRITE_CHAN"
+
+ if [ "$ONLINE" -eq "1" ]; then
+ add_channel_for_cio "$CTC_READ_CHAN,$CTC_WRITE_CHAN"
+ # Write a new udev rules file
+ cat > ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} < ] <ccwid> <online> [use_diag]
#
-# -f Override safety checks
-# -t DASD type. Must be provided if -f is used. Only dasd-eckd and
-# dasd-fba are supported - Deprecated
+# -f force creation of udev rules, do not check values in /sys.
+# -t DASD type. Must be provided if -f is used.
# ccwid = x.y.ssss where
# x is always 0 until IBM creates something that uses that number
-# y is the logical channel subsystem (lcss) number. Most often
-# this is 0, but it could be non-zero
-# ssss is the four digit subchannel address of the device, in
-# hexidecimal, with leading zeros.
+# y is the logical channel subsystem (lcss) number. Most often this is 0, but it could be non-zero
+# ssss is the four digit subchannel address of the device, in hexidecimal, with leading zeros.
# online = 0 to take the device offline
# 1 to bring the device online
# use_diag = 0 to _not_ use z/VM DIAG250 I/O, which is the default
# 1 to use z/VM DIAG250 I/O
#
# Return values:
-# Return codes are determined by the chzdev command.
+# 1 If the "Usage:" line is displayed, not enough parameters specified.
+# 1 sysfs not mounted (if the "Usage:" line is not displayed).
+# 2 Invalid status for <online>
+# 3 No device found for <ccwid>
+# 4 Could not change state of the device
+# 5 Device is not a DASD
+# 6 Could not load module
+# 7 Failed to activate DASD
+# 8 DASD not formatted
+# 9 Only dasd-fba or dasd-eckd is supported.
#
+if [ "${DEBUG}" != "yes" ]; then
+ DEBUG="no"
+fi
+
+exitcode=0
+DASD_FORCE=0
+DASD_TYPE="unknown"
+
+DATUM=$(date)
+
+add_channel_for_cio() {
+ echo "$* # $DATUM" >> /boot/zipl/active_devices.txt
+}
+
+remove_channel_for_cio() {
+ [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^$1/d" /boot/zipl/active_devices.txt
+}
+
mesg () {
echo "$@"
}
debug_mesg () {
- case "${DEBUG}" in
+ case "$DEBUG" in
yes) mesg "$@" ;;
*) ;;
esac
}
-add_cio_channel() {
- echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
-}
-
-remove_cio_channel() {
- [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
-}
-
-usage(){
- echo "Usage: ${0} [-f -t ] <ccwid> <online> [use_diag]"
- echo
- echo " -f Override safety checks"
- echo " -t DASD type. Must be provided if -f is used. Only dasd-eckd and"
- echo " dasd-fba are supported - Deprecated"
- echo " ccwid = x.y.ssss where"
- echo " x is always 0 until IBM creates something that uses that number"
- echo " y is the logical channel subsystem (lcss) number. Most often"
- echo " this is 0, but it could be non-zero"
- echo " ssss is the four digit subchannel address of the device, in"
- echo " hexidecimal, with leading zeros."
- echo " online = 0 to take the device offline"
- echo " 1 to bring the device online"
- echo " use_diag = 0 to _not_ use z/VM DIAG250 I/O, which is the default"
- echo " 1 to use z/VM DIAG250 I/O"
-}
-
-if [ "${DEBUG}" != "yes" ]; then
- DEBUG="no"
+if [ $# -lt 2 ] ; then
+ echo "Usage: $0 [options] <ccwid> <online> [use_diag]"
+ echo
+ echo " -f force creation of udev rules, do not check values in /sys."
+ echo " -t DASD type. Must be provided if -f is used."
+ echo " ccwid = x.y.ssss where"
+ echo " x is always 0 until IBM creates something that uses that number"
+ echo " y is the logical channel subsystem (lcss) number. Most often this is 0, but it could be non-zero"
+ echo " ssss is the four digit subchannel address of the device, in hexidecimal, with leading zeros."
+ echo " online = 0 to take the device offline"
+ echo " 1 to bring the device online"
+ echo " use_diag = 0 to _not_ use z/VM DIAG250 I/O, which is the default"
+ echo " 1 to use z/VM DIAG250 I/O"
+ exit 1
fi
-DATE=$(date)
-
-DASD_FORCE=0
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ -f) # force creation of udev rules, do not check values in /sys
+ DASD_FORCE=1
+ ;;
+ -t*) # drive type. Must be provided if -f is used.
+ if [ "$1" = "-t" ] ; then
+ if [ "$2" = "dasd-eckd" -o "$2" = "dasd-fba" ]; then
+ DASD_TYPE=$2
+ shift
+ else
+ debug_mesg "Only dasd-eckd or dasd-fba are supported."
+ exit 9
+ fi
+ fi
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ shift
+done
-############################################################
-# Parse the parameters from the command line
-#
-ARGS=$(getopt --options ft: -n "dasd_configure" -- "$@")
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+if [ $DASD_FORCE -eq 0 ]; then
+ # Get the mount point for sysfs
+ while read MNTPT MNTDIR MNTSYS MNTTYPE; do
+ if test "$MNTSYS" = "sysfs"; then
+ SYSFS="$MNTDIR"
+ break;
+ fi
+ done &1 > /dev/null
+ if [ -x /sbin/vmcp -a $? -eq 0 ]; then
+ # Unconditionally load the vmcp module, loader might be broken
+ [ -x /sbin/modprobe ] && /sbin/modprobe -q vmcp
+ # Wait until udev is settled
+ [ -x /sbin/udevadm ] && /sbin/udevadm settle --timeout=30
+
+ # Check read-only status of virtual DASDs from z/VM
+ if /sbin/vmcp q v dasd > /dasd_attr.lst 2> /dev/null; then
+ while read x dev type label attr1 attr2 rest; do
+ dev=`echo $dev|tr A-F a-f`
+ if test "$type" = "ON"; then
+ attr="$attr2"
+ else
+ attr="$attr1"
+ fi
+ if [ "$CCW_CHAN_ID" = "0.0.$dev" ]; then
+ if test "$attr" = "R/O"; then
+ _ccw_use_readonly="1"
+ fi
+ fi
+ done < /dasd_attr.lst
+ fi
+ rm -f /dasd_attr.lst
+ fi # if [ -x /sbin/vmcp -a $? -eq 0 ]
+
+ if [ "$ONLINE" -eq 1 ]; then
+ # Check whether we need to do something
+ read _ccw_use_diag < $_ccw_status_dir/use_diag
+
+ if [ "$_ccw_use_diag" -ne "$USE_DIAG" ] &&
+ [ "$_ccw_dev_status" -eq 1 ] ; then
+ # We need to change the DIAG access mode
+ # so we have to set the device offline first
+ debug_mesg "Setting device offline for DIAG access"
+ echo "0" > $_ccw_status_dir/online
+ # Re-read device status
+ read _ccw_dev_status < $_ccw_status_dir/online
+ if [ "$_ccw_dev_status" -ne 0 ]; then
+ mesg "Could not set the device offline for DIAG access"
+ exit 4
+ fi
+ fi
+
+ if [ "$_ccw_dev_status" -eq 0 ]; then
+ # Set readonly access if detected
+ if [ "$_ccw_use_readonly" ]; then
+ debug_mesg "Setting device read-only"
+ echo 1 > $_ccw_status_dir/readonly
+ fi
+
+ if [ "$USE_DIAG" -eq 1 ]; then
+ # Load the diag module if possible
+ [ -x /sbin/modprobe ] && /sbin/modprobe -q dasd_diag_mod
+ _has_dasd_diag=$(/bin/sed -n '/^dasd_diag_mod/p' /proc/modules)
+ if [ "$_has_dasd_diag" ]; then
+ # DIAG mode is special:
+ # We can only be sure if DIAG is available
+ # _after_ we have activated the device
+ debug_mesg "Activating DIAG access mode"
+ echo "$USE_DIAG" > $_ccw_status_dir/use_diag
+ read _ccw_use_diag < $_ccw_status_dir/use_diag
+ # Set the device online
+ debug_mesg "Setting device online"
+ echo "1" > $_ccw_status_dir/online 2>/dev/null
+ # Re-read device status
+ read _ccw_dev_status < $_ccw_status_dir/online
+ if [ "$_ccw_dev_status" -eq 0 ]; then
+ mesg "Could not activate DIAG access mode for device ${CCW_CHAN_ID}"
+ USE_DIAG=0
+ echo "$USE_DIAG" > $_ccw_status_dir/use_diag
+ # Set the device online
+ debug_mesg "Setting device online"
+ echo "1" > $_ccw_status_dir/online
+ else
+ MODULE=dasd_diag_mod
+ fi
+ else
+ debug_mesg "DIAG mode not available"
+ USE_DIAG=0
+ # Set the device online
+ debug_mesg "Setting device online"
+ echo "1" > $_ccw_status_dir/online
+ fi # if [ "$_has_dasd_diag" ];
+ else
+ if [ "$_ccw_use_diag" -eq 1 ] ; then
+ debug_mesg "Deactivating DIAG access mode"
+ echo "0" > $_ccw_status_dir/use_diag
+ read _ccw_use_diag < $_ccw_status_dir/use_diag
+ fi
+ # Set the device online
+ debug_mesg "Setting device online"
+ echo "1" > $_ccw_status_dir/online
+ fi # if [ "$USE_DIAG" -eq 1 ]
+
+ # Re-read device status
+ read _ccw_dev_status < $_ccw_status_dir/online
+ if [ "$_ccw_dev_status" -eq 0 ]; then
+ mesg "Could not set device ${CCW_CHAN_ID} online"
+ exit 4
+ fi
+
+ # Wait for the device to come online
+ read _dasd_state < $_ccw_status_dir/status
+ i=0
+ while [ "$_dasd_state" != "online" ] ; do
+ if [ "$_dasd_state" = "unformatted" ] ; then
+ mesg "Device ${CCW_CHAN_ID} is unformatted"
+ exitcode=8
+ break
+ fi
+ [ $i -gt 30 ] && break
+ i=$(expr $i + 1)
+ sleep .1
+ read _dasd_state < $_ccw_status_dir/status
+ done
+ else
+ debug_mesg "Device ${CCW_CHAN_ID} is already online"
+ fi # if [ "$_ccw_dev_status" -eq 0 ]
+
+ read _dasd_state < $_ccw_status_dir/status
+ if [ "$_dasd_state" != "online" ] && [ "$_dasd_state" != "unformatted" ] ; then
+ mesg "Failed to activate device ${CCW_CHAN_ID}, device in state $_dasd_state"
+ exit 7
+ fi
+ else
+ if [ "$_ccw_dev_status" -eq 1 ]; then
+ # Set the device offline
+ debug_mesg "Setting device offline"
+ echo "$ONLINE" > $_ccw_status_dir/online
+
+ # Re-read to check whether we have succeeded
+ _ccw_dev_status=$(cat $_ccw_status_dir/online)
+ if [ "$?" -ne 0 -o "$_ccw_dev_status" -ne "$ONLINE" ]; then
+ mesg "Could not set device ${CCW_CHAN_ID} offline"
+ exit 4
+ fi
+ else
+ debug_mesg "Device ${CCW_CHAN_ID} is already offline"
+ fi
+
+ if [ -d "$_ccw_status_dir" ] ; then
+ # Always disabling DIAG access
+ echo "0" > $_ccw_status_dir/use_diag
+ fi
+
+ # Set readonly access if detected
+ if [ "$_ccw_use_readonly" ]; then
+ debug_mesg "Setting device read-only"
+ echo 1 > $_ccw_status_dir/readonly
+ fi
+ fi # if [ "$ONLINE" -eq 1 ]
+
+ # Wait until udev is settled
+ [ -x /sbin/udevadm ] && /sbin/udevadm settle --timeout=30
+
+fi # Second instance of if [ $DASD_FORCE -eq 0 ]
+
+if [ $DEBUG = "no" ]; then
+ RULES_DIR=/etc/udev/rules.d
+else
+ RULES_DIR=.
fi
-if [ "${ON_OFF}" == 0 ]; then
- debug_mesg "chzdev -d dasd ${CCW_CHAN_ID}"
- chzdev -d dasd ${CCW_CHAN_ID}
-elif [ "${ON_OFF}" == 1 ]; then
- debug_mesg "chzdev -e dasd ${CCW_CHAN_ID} ${PARM_LIST}"
- chzdev -e dasd ${CCW_CHAN_ID} ${PARM_LIST}
-else mesg "You must specify a 0 or a 1 for the online/offline attribute."
- usage
- exit 1
-fi
+RULES_FILE=51-dasd-${CCW_CHAN_ID}.rules
-RC=${?}
-if [ ${RC} -ne 0 ]; then
- exit ${RC}
+if [ -d "$RULES_DIR" ]; then
+ if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
+ rm -f ${RULES_DIR}/${RULES_FILE}
+ fi
+ remove_channel_for_cio "${CCW_CHAN_ID}"
+
+ if [ "$ONLINE" -eq "1" ]; then
+ add_channel_for_cio "${CCW_CHAN_ID}"
+ # Write a new hwcfg file
+ cat > ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> /boot/zipl/active_devices.txt
+add_channel_for_cio() {
+ echo "$* # $DATUM" >> /boot/zipl/active_devices.txt
}
-remove_cio_channel() {
- [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
+remove_channel_for_cio() {
+ [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^$1/d" /boot/zipl/active_devices.txt
}
-usage(){
- echo "Usage: ${0} [options] <read chan> <write chan> <data chan> <online>"
- echo " -i Configure IP takeover"
- echo " -l Configure Layer2 support"
- echo " -f Override safety checks"
- echo " -t Valid cardtypes are: qeth, hsi - Deprecated."
- echo " -o General QETH options, separated by spaces"
- echo " -n QETH port number to use, 0 or 1. Only needed for real, not virtual"
- echo " devices."
- echo " -p QETH Portname to use - Deprecated. OSAs no longer need a port name."
- echo " read/write/data chan = x.y.ssss where"
- echo " x is always 0 until IBM creates something that"
- echo " uses that number"
- echo " y is the logical channel subsystem (lcss)"
- echo " number. Most often this is 0, but it could"
- echo " be non-zero"
- echo " ssss is the four digit subchannel address of"
- echo " the device, in hexidecimal, with leading"
- echo " zeros."
- echo " online = 0 to take the device offline"
- echo " 1 to bring the device online"
+debug_mesg () {
+ case "$DEBUG" in
+ yes) mesg "$@" ;;
+ *) ;;
+ esac
}
-if [ "${DEBUG}" != "yes" ]; then
- DEBUG="no"
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ -i)
+ # Configure IP takeover
+ QETH_IPA_TAKEOVER=1
+ ;;
+ -f) # force creation of udev rules, do not check values in /sys
+ QETH_FORCE=1
+ ;;
+ -l)
+ # Configure Layer2 support
+ QETH_LAYER2_SUPPORT=1
+ ;;
+ -n*)
+ # QETH port number to use
+ if [ "$1" = "-n" ] ; then
+ QETH_PORTNO=$2
+ shift
+ else
+ QETH_PORTNO=${1#-n}
+ fi
+ ;;
+ -o)
+ # General QETH options, separated by spaces
+ QETH_OPTIONS=$2
+ shift
+ ;;
+ -p*)
+ # QETH Portname to use
+ if [ "$1" = "-p" ] ; then
+ QETH_PORTNAME=$2
+ shift
+ else
+ QETH_PORTNAME=${1#-p}
+ fi
+ ;;
+ -t*) # Card type. Must be provided if -f is used.
+ if [ "$1" = "-t" ] ; then
+ if [ "$2" = "qeth" -o "$2" = "hsi" -o "$2" = "osn" ]; then
+ QETH_CARD=$2
+ shift
+ else
+ mesg "Only qeth, hsi and osn are supported."
+ exit 6
+ fi
+ fi
+ CCW_DRV="$QETH_CARD"
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ shift
+done
+
+if [ $QETH_FORCE -eq 0 ]; then
+# Get the mount point for sysfs
+ while read MNTPT MNTDIR MNTSYS MNTTYPE; do
+ if test "$MNTSYS" = "sysfs"; then
+ SYSFS="$MNTDIR"
+ break;
+ fi
+ done &2 ; exit 1 ; fi
+if [ -z "$ONLINE" ] || [ "$ONLINE" -ne "1" -a "$ONLINE" -ne "0" ]; then
+ mesg "Invalid device status $ONLINE"
+ exit 2
+fi
+
+if [ $QETH_FORCE -eq 0 ]; then
+_ccw_dir=${SYSFS}/bus/ccw/devices
-eval set -- "${ARGS}"
-debug_mesg "All the parms passed were ${ARGS}"
-
-# Set some defaults
-LAYER_MODE="layer2=0"
-
-while true; do
- case "${1}" in
- -i) debug_mesg "Configure IP takeover"
- PARM_LIST="${PARM_LIST} ipa_takeover/enable=1"
- shift 1
- ;;
- -f) debug_mesg "This used to mean udev rules will always be generated."
- debug_mesg "For chzdev, it means safety checks will be overridden."
- debug_mesg "Kinda sorta the same thing, really."
- PARM_LIST="${PARM_LIST} -f"
- shift 1
- ;;
- -l) debug_mesg "Configure Layer 2 support"
- LAYER_MODE="layer2=1"
- shift 1
- ;;
- -n) debug_mesg "Set QETH port number to ${2}"
- PARM_LIST="${PARM_LIST} portno=${2}"
- shift 2
- ;;
- -o) debug_mesg "Add the following arbitrary parms: ${2}"
- PARM_LIST="${PARM_LIST} ${2}"
- shift 2
- ;;
- -p) debug_mesg "QETH Port name is no longer used, don't specify it: ${2}"
- shift 2
- ;;
- -t) debug_mesg "This used to set the card type to ${2}"
- debug_mesg "Now it gets ignored."
- shift 2
- ;;
- --) debug_mesg "Found the end of parms indicator: --"
- shift 1
- break
- ;;
- *) debug_mesg "At the catch-all select entry"
- debug_mesg "What was selected was ${1}"
- shift 1
- ;;
- esac
+# Convert any hexidecimal numbers to lower case
+QETH_READ_CHAN=$(echo ${QETH_READ_CHAN} | tr "[A-Z]" "[a-z]")
+QETH_WRITE_CHAN=$(echo ${QETH_WRITE_CHAN} | tr "[A-Z]" "[a-z]")
+QETH_DATA_CHAN=$(echo ${QETH_DATA_CHAN} | tr "[A-Z]" "[a-z]")
+
+debug_mesg "Configuring QETH device ${QETH_READ_CHAN}/${QETH_WRITE_CHAN}/${QETH_DATA_CHAN}"
+
+
+if test ! -d "$_ccw_dir/$QETH_READ_CHAN" ; then
+ mesg "No device ${QETH_READ_CHAN}"
+ exit 3
+fi
+if test ! -d "$_ccw_dir/$QETH_WRITE_CHAN" ; then
+ mesg "No device ${QETH_WRITE_CHAN}"
+ exit 4
+fi
+if test ! -d "$_ccw_dir/$QETH_DATA_CHAN" ; then
+ mesg "No device ${QETH_DATA_CHAN}"
+ exit 5
+fi
+
+CCW_CHAN_GROUP=
+for ccw in $_ccw_dir/$QETH_READ_CHAN $_ccw_dir/$QETH_WRITE_CHAN $_ccw_dir/$QETH_DATA_CHAN; do
+
+ read _cu_type < $ccw/cutype
+ read _dev_type < $ccw/devtype
+
+ case "$_cu_type" in
+ 1731/01|1731/02)
+ # OSA/Express / Guest LAN
+ CCW_DRV="qeth"
+ QETH_CARD="qeth"
+ ;;
+ 1731/05)
+ # Hipersockets
+ CCW_DRV="qeth"
+ QETH_CARD="hsi"
+ ;;
+ 1731/06)
+ # OSA/N
+ CCW_DRV="qeth"
+ QETH_CARD="osn"
+ ;;
+ *)
+ CCW_DRV=
+ ;;
+ esac
+
+ if [ -z "$CCW_DRV" ]; then
+ mesg "Not a valid QETH device (cu $_cutype, dev $_devtype)"
+ exit 6
+ fi
done
+fi # end QETH_FORCE
+
+# Portname is only required for OSA/Express
+if [ -n "$QETH_PORTNAME" -a "$QETH_CARD" != "qeth" ] ; then
+ debug_mesg "No portname required for $QETH_CARD adapters"
+ QETH_PORTNAME=
+fi
-QETH_READ_CHAN=${1}
-QETH_WRITE_CHAN=${2}
-QETH_DATA_CHAN=${3}
-ON_OFF=${4}
-
-if [ -z "${QETH_READ_CHAN}" ] || [ -z "${QETH_WRITE_CHAN}" ] || [ -z "${QETH_DATA_CHAN}" ] || [ -z "${ON_OFF}" ]; then
- mesg "You didn't specify all the needed parameters."
- usage
- exit 1
-fi
-
-if [ "${ON_OFF}" == 0 ]; then
- debug_mesg "chzdev -d qeth ${QETH_READ_CHAN}"
- chzdev -d qeth ${QETH_READ_CHAN}
-elif [ "${ON_OFF}" == 1 ]; then
- debug_mesg "chzdev -e qeth ${LAYER_MODE} ${PARM_LIST} ${QETH_READ_CHAN}"
- chzdev -e qeth ${LAYER_MODE} ${PARM_LIST} ${QETH_READ_CHAN}
-else mesg "You must specify a 0 or a 1 for the online/offline attribute."
- usage
- exit 1
-fi
-
-RC=${?}
-if [ ${RC} -ne 0 ]; then
- exit ${RC}
-fi
-
-if [ ${ON_OFF} == 1 ]; then
- add_cio_channel "${QETH_READ_CHAN},${QETH_WRITE_CHAN},${QETH_DATA_CHAN}"
-else remove_cio_channel "${QETH_READ_CHAN}"
- remove_cio_channel "${QETH_WRITE_CHAN}"
- remove_cio_channel "${QETH_DATA_CHAN}"
+if [ $QETH_FORCE -eq 0 ]; then
+_ccw_groupdir=${SYSFS}/bus/ccwgroup
+
+# Check for modules
+if test ! -d "${_ccw_groupdir}/drivers/${CCW_DRV}" ; then
+ /sbin/modprobe $CCW_DRV
+
+ # Re-check whether module loading has succeeded
+ if test ! -d "${_ccw_groupdir}/drivers/${CCW_DRV}"; then
+ mesg "Could not load module ${CCW_DRV}"
+ exit 7
+ fi
+fi
+
+# Check for grouping
+_ccwgroup_dir=
+if [ -e ${_ccw_dir}/${QETH_READ_CHAN}/group_device ] ; then
+ _ccwgroup_dir=$(cd -P ${_ccw_dir}/${QETH_READ_CHAN}/group_device; echo $PWD)
+fi
+if [ -e ${_ccw_dir}/${QETH_WRITE_CHAN}/group_device ] ; then
+ _tmp_status_dir=$(cd -P ${_ccw_dir}/${QETH_READ_CHAN}/group_device; echo $PWD)
+ if [ "$_ccwgroup_dir" ] && [ "$_ccwgroup_dir" != "$_tmp_status_dir" ] ; then
+ mesg "CCW devices grouped to different devices"
+ exit 8
+ fi
+ _ccwgroup_dir=$_tmp_status_dir
+fi
+if [ -e ${_ccw_dir}/${QETH_DATA_CHAN}/group_device ] ; then
+ _tmp_status_dir=$(cd -P ${_ccw_dir}/${QETH_DATA_CHAN}/group_device; echo $PWD)
+ if [ "$_ccwgroup_dir" ] && [ "$_ccwgroup_dir" != "$_tmp_status_dir" ] ; then
+ mesg "CCW devices grouped to different devices"
+ exit 8
+ fi
+ _ccwgroup_dir=$_tmp_status_dir
+fi
+if [ -z "$_ccwgroup_dir" ] ; then
+ echo "$QETH_READ_CHAN,$QETH_WRITE_CHAN,$QETH_DATA_CHAN" > ${_ccw_groupdir}/drivers/${CCW_DRV}/group
+ if [ -e ${_ccw_dir}/${QETH_READ_CHAN}/group_device ] ; then
+ _ccwgroup_dir=$(cd -P ${_ccw_dir}/${QETH_READ_CHAN}/group_device; echo $PWD)
+ fi
fi
+
+if [ -z "$_ccwgroup_dir" -o ! -e "$_ccwgroup_dir" ] ; then
+ mesg "Could not group $CCW_DRV devices $QETH_READ_CHAN/$QETH_WRITE_CHAN/$QETH_DATA_CHAN"
+ exit 9
+fi
+
+CCW_CHAN_ID=${_ccwgroup_dir##*/}
+
+read _online < $_ccwgroup_dir/online
+
+if [ "$ONLINE" -eq 1 ]; then
+ # Check whether we need to do something
+ # We do not check for the value of CCW_CHAN_MODE, since we
+ # might want to switch back and forth between several modes
+ if test "$_online" -eq "0" ; then
+ # Set the portname
+ if [ "$QETH_PORTNAME" ]; then
+ mesg "(portname $QETH_PORTNAME) "
+ echo "$QETH_PORTNAME" > $_ccwgroup_dir/portname
+ fi
+ # Activate Layer2 support
+ if [ -w "$_ccwgroup_dir/layer2" ] ; then
+ if [ "$QETH_LAYER2_SUPPORT" = "1" ]; then
+ mesg "(Layer2) "
+ echo 1 > $_ccwgroup_dir/layer2
+ else
+ echo 0 > $_ccwgroup_dir/layer2
+ fi
+ else
+ QETH_LAYER2_SUPPORT=
+ fi
+ # Enable IP address takeover
+ if [ "$QETH_IPA_TAKEOVER" ]; then
+ if [ "$QETH_IPA_TAKEOVER" = "1" ]; then
+ mesg "(IP takeover) "
+ echo 1 > $_ccwgroup_dir/ipa_takeover/enable
+ fi
+ fi
+ # Relative port number
+ if [ -w "$_ccwgroup_dir/portno" ] ; then
+ if [ -n "$QETH_PORTNO" ]; then
+ mesg "(Port $QETH_PORTNO) "
+ # This may fail, but trial and error is the only way to tell.
+ echo "$QETH_PORTNO" > $_ccwgroup_dir/portno
+ fi
+ else
+ unset QETH_PORTNO
+ fi
+ # Set additional options
+ if [ "$QETH_OPTIONS" ]; then
+ for opt in $QETH_OPTIONS; do
+ set -- $(IFS='='; echo $opt)
+ opt_name=$1
+ opt_val=$2
+ case "$opt_name" in
+ portname|ipa_takeover|layer2)
+ # These options are set above
+ debug_mesg "Invalid option $opt_name"
+ ;;
+ *)
+ if [ "$opt_name" -a "$opt_val" ]; then
+ if [ -w "$_ccwgroup_dir/$opt_name" ]; then
+ mesg "($opt_name) "
+ echo "$opt_val" > $_ccwgroup_dir/$opt_name
+ if [ $? -eq 0 ] ; then
+ cur_opts="$cur_opts ${opt_name}=${opt_val}"
+ fi
+ else
+ # Skip invalid options
+ debug_mesg "Invalid option $opt_name"
+ fi
+ fi
+ ;;
+ esac
+ done
+ # Update options list
+ QETH_OPTIONS="$cur_opts"
+ fi
+
+ echo "1" > $_ccwgroup_dir/online 2> /dev/null
+ # Re-read device status
+ read _ccw_dev_status < $_ccwgroup_dir/online
+ if [ "$_ccw_dev_status" -eq 0 ]; then
+ mesg "Could not set device ${CCW_CHAN_ID} online"
+ exit 10
+ fi
+ else
+ debug_mesg "Device ${CCW_CHAN_ID} is already online"
+ fi
+else
+ if [ "$_online" -eq 1 ]; then
+ # Set the device offline
+ debug_mesg "Setting device offline"
+ echo "$ONLINE" > $_ccwgroup_dir/online
+
+ # Re-read to check whether we have succeeded
+ _online=$(cat $_ccwgroup_dir/online)
+ if [ "$_online" -ne "$ONLINE" ]; then
+ mesg "Could not set device ${CCW_CHAN_ID} offline"
+ exit 11
+ fi
+ else
+ debug_mesg "Device ${CCW_CHAN_ID} is already offline"
+ fi
+ echo 1 > $_ccwgroup_dir/ungroup
+fi
+else
+ CCW_CHAN_ID=$QETH_READ_CHAN
+fi # QETH_FORCE
+
+if [ $DEBUG = "no" ]; then
+ RULES_DIR=/etc/udev/rules.d
+else
+ RULES_DIR=.
+fi
+
+RULES_FILE=51-${QETH_CARD}-${CCW_CHAN_ID}.rules
+
+if [ -d "$RULES_DIR" ]; then
+ if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
+ rm -f ${RULES_DIR}/${RULES_FILE}
+ fi
+ remove_channel_for_cio "${QETH_READ_CHAN}"
+ remove_channel_for_cio "${QETH_WRITE_CHAN}"
+ remove_channel_for_cio "${QETH_DATA_CHAN}"
+
+ if [ "$ONLINE" -eq "1" ]; then
+ add_channel_for_cio "${QETH_READ_CHAN},${QETH_WRITE_CHAN},${QETH_DATA_CHAN}"
+ # Write a new udev rules file
+ cat > ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} < ${_zfcp_wwpn_dir}/unit_add
+ /sbin/udevadm settle
+ fi
+ # Re-check whether the disk could be activated
+ if [ ! -d "${_zfcp_wwpn_dir}/0x${FCP_LUN}" ] ; then
+ mesg "Could not activate FCP disk ${FCP_WWPN}:${FCP_LUN}"
+ exit 6
+ fi
+ # Check for failed disks
+ read wwpn_status < ${_zfcp_wwpn_dir}/0x${FCP_LUN}/status
+ while [ "$wwpn_status" != 0 ] ; do
+ sleep 1
+ read wwpn_status < ${_zfcp_wwpn_dir}/0x${FCP_LUN}/in_recovery
+ [ "$wwpn_status" = 0 ] && break
+ done
+ read wwpn_status < ${_zfcp_wwpn_dir}/0x${FCP_LUN}/failed
+ if [ "$wwpn_status" = 1 ] ; then
+ debug_mesg "ERP failed on FCP disk ${FCP_WWPN}:${FCP_LUN}"
+ exit 7
+ fi
+ fi
+else
+ # Deconfigure SCSI disk
+ debug_mesg "Deconfiguring FCP disk ${FCP_WWPN}:${FCP_LUN}"
+
+ _zfcp_wwpn_dir="${_zfcp_dir}/0x${FCP_WWPN}"
+ # Find the correspondig SCSI disk
+ for host_dir in $_zfcp_dir/host*; do
+ if [ -d $host_dir ] ; then
+ _zfcp_scsi_host_dir=$host_dir
+ break;
+ fi
+ done
+ if [ -d "$_zfcp_scsi_host_dir" ] ; then
+ # Deregister the disk from SCSI layer
+ for target in $_zfcp_scsi_host_dir/rport-*/target*/* ; do
+ [ "$target" != "${target##*/fc_transport}" ] && continue
+ if [ -d "$target" ] && [ -d "$target/scsi_device" ] ; then
+ _zfcp_scsi_id=${target##*/}
+ read _zfcp_tmp_hba < ${target}/hba_id
+ read _zfcp_tmp_wwpn < ${target}/wwpn
+ read _zfcp_tmp_lun < ${target}/fcp_lun
+ if [ "0x${FCP_LUN}" = "$_zfcp_tmp_lun" -a "0x${FCP_WWPN}" = "$_zfcp_tmp_wwpn" ] ; then
+ if [ "$auto_lun_scan" = 1 ] ; then
+ mesg "Could not deactivate SCSI disk ${_zfcp_scsi_id}"
+ exit 7
+ else
+ echo 1 > $target/delete
+ _zfcp_scsi_dir=$target
+ fi
+ break;
+ fi
+ fi
+ done
+ /sbin/udevadm settle
+ else
+ debug_mesg "No SCSI disk found for FCP disk ${FCP_WWPN}:${FCP_LUN}"
+ fi
+
+ # Re-check whether the SCSI disk is gone
+ num=$udev_timeout
+ while [ $num -gt 0 ] ; do
+ [ -d "${_zfcp_scsi_dir}" ] || break
+ let num=$num-1
+ sleep 1
+ done
+ if [ -d "${_zfcp_scsi_dir}" ]; then
+ mesg "Could not deactivate SCSI disk ${_zfcp_scsi_id}"
+ exit 7
+ fi
+
+ # Wait for udev to catch up
+ /sbin/udevadm settle
+
+ # check multipathing
+ _zfcp_scsi_dev=$(multipathd -k'show paths' 2> /dev/null | sed -n "s/$_zfcp_scsi_id \(sd[a-z]*\).*/\1/p")
+ [ "$_zfcp_scsi_dev" ] && multipathd -k"del path $_zfcp_scsi_dev"
+
+ # Deconfigure the FCP_LUN
+ : ${_zfcp_wwpn_dir}
+ echo "0x${FCP_LUN}" > ${_zfcp_wwpn_dir}/unit_remove
+ if [ -d "${_zfcp_wwpn_dir}/0x${FCP_LUN}" ]; then
+ mesg "Could not deregister FCP LUN ${FCP_LUN}"
+ exit 8
+ fi
+
+ # Find all remaining activated disks
+ ZFCP_LUNS=
+ for _tmp_wwpn_dir in ${_zfcp_dir}/0x*; do
+ if [ -d "$_tmp_wwpn_dir" ]; then
+ tmp_wwpn=$(basename $_tmp_wwpn_dir)
+ # Find all luns
+ for _tmp_lun_dir in ${_tmp_wwpn_dir}/0x*; do
+ if [ -d "$_tmp_lun_dir" ]; then
+ tmp_lun=$(basename $_tmp_lun_dir)
+ tmp_port="${tmp_wwpn}:${tmp_lun}"
+ ZFCP_LUNS="$ZFCP_LUNS
+$tmp_port"
+ fi
+ done
+ fi
+ done
+fi
+
+# And now update the rules file
+if test -d ${RULES_DIR}; then
+ # Find all WWPNs
+
+ read online < ${_zfcp_dir}/online;
+ if [ $online -eq 0 ] ; then
+ exit 0
+ fi
+
+ for port in ${_zfcp_dir}/0x* ; do
+ [ -d $port ] || continue;
+ [ -w $port/unit_remove ] || continue;
+ port_list="$port_list ${port##*/}"
+ done
+
+ cat > ${RULES_DIR}/${RULES_FILE} <> ${RULES_DIR}/${RULES_FILE} <> /boot/zipl/active_devices.txt
+}
+
+remove_channel_for_cio() {
+ [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^$1/d" /boot/zipl/active_devices.txt
+}
+
mesg () {
echo "$@"
}
debug_mesg () {
- case "${DEBUG}" in
- yes) mesg "$@" ;;
- *) ;;
+ case "$DEBUG" in
+ yes) mesg "$@" ;;
+ *) ;;
esac
}
-add_cio_channel() {
- echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
-}
+if [ $# -ne 2 ] ; then
+ echo "Usage: $0 <ccwid> <online>"
+ echo " ccwid = x.y.ssss where"
+ echo " x is always 0 until IBM creates something that uses that number"
+ echo " y is the logical channel subsystem (lcss) number. Most often this is 0, but it could be non-zero"
+ echo " ssss is the four digit subchannel address of the device, in hexidecimal, with leading zeros."
+ echo " online = 0 to take the device offline"
+ echo " 1 to bring the device online"
+ exit 1
+fi
-remove_cio_channel() {
- [ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
-}
+# Get the mount point for sysfs
+while read MNTPT MNTDIR MNTSYS MNTTYPE; do
+ if test "$MNTSYS" = "sysfs"; then
+ SYSFS="$MNTDIR"
+ break;
+ fi
+done $_zfcp_dir/online
+
+ # Now wait for the adapter to initialize
+ /sbin/udevadm settle
+ fi
+
+ for loop in 1 2 3 4 5 ; do
+ read status < /sys/bus/ccw/devices/$CCW_CHAN_ID/status
+ (( $status & 0x10000000 )) && break;
+ done
+ read wwpn_status < /sys/bus/ccw/devices/$CCW_CHAN_ID/status
+ if !(( $wwpn_status & 0x10000000 )) ; then
+ echo 0 > /sys/bus/ccw/devices/$CCW_CHAN_ID/online
+ mesg "Could not activate adapter, status $wwpn_status"
+ exit 5
+ fi
+
+ # Write the configuration file
+ if test -d ${RULES_DIR}; then
+ cat > ${RULES_DIR}/${RULES_FILE} < ${_zfcp_dir}/online
+ # Re-read to check whether we have succeeded
+ _ccw_dev_status=$(cat $_zfcp_dir/online)
+ if [ "$_ccw_dev_status" -ne "$ONLINE" ]; then
+ mesg "Could not change status of device ${CCW_CHAN_ID} to $ONLINE"
+ exit 5
+ fi
+ echo "${CCW_CHAN_ID}" > /sys/bus/ccw/drivers/zfcp/unbind
+ echo "${CCW_CHAN_ID}" > /sys/bus/ccw/drivers/zfcp/bind
+ remove_channel_for_cio "${CCW_CHAN_ID}"
+
+ debug_mesg "zFCP adapter at ${CCW_CHAN_ID} deactivated"
fi
+
+# EOF