#!/bin/sh # # zfcp_host_configure # # Configures a zfcp host adapter # # Usage: # zfcp_host_configure # # 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. # online = 0 to take the device offline # 1 to bring the device online # # Return codes # 1 sysfs not mounted # 2 invalid value for # 3 device does not exist # 4 module zfcp could not be loaded # 5 adapter status could not be changed # 6 wwpn ports still active # 10 adapter active but allow_lun_scan active # 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 "$@" ;; *) ;; esac } if [ $# -ne 2 ] ; then echo "Usage: $0 " 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 # 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