forked from pool/s390-tools
6a6c0cb679
*** v2.34.0 * Changes of existing tools: - ap_tools/ap-check: Add support for vfio-ap dynamic configuration - dbginfo.sh: Update/Add additional DASD data collection - dumpconf: Add new parameter 'SCP_DATA' for SCSI/NVMe/ECKD dump devices - libutil: Make formatted meta-data configurable - s390-tools: Replace 'which' with built-in 'command -v' - zdump/dfi_elf: Support core dumps of vr-kernels * Bug Fixes: - chzdev: Fix warning about failed ATTR writes by udev - rust/pv: Try again if first CRL-URI is invalid - rust/pvattest: Add short option for --arpk - zdump: Fix 'zgetdump -i' ioctl error on s390 formatted dump file *** v2.33.1 * Bug Fixes: - s390-tools: Fix formatting and typos in README.md - s390-tools: Fix release string *** v2.33.0 * Add new tools / libraries: - chpstat: New tool for displaying channel path statistics - libutil: Add output format helpers(util_fmt: JSON, JSON-SEQ, CSV, text pairs) * Changes of existing tools / libraries: - chzdev: Add --is-owner to identify files created by zdev - dasdfmt: Change default mode to always use full-format (Note: affects ESE DASD) - libap: Significantly reduce delay time between file lock retries - pvattest: Rewrite from C to Rust - pvattest: Support additional data & user-data - rust/pv: Support for Attestation * Bug Fixes: - chreipl: Improve disk type detection when running under QEMU - dbginfo.sh: Use POSIX option with uname - s390-tools: Fix missing hyphen escapes in the man page for many tools - zipl/src: Fix bugs in disk_get_info() reproducible in corner cases *** v2.32.0 * Changes of existing tools: - cpumf/lscpumf: add support for machine type 3932 - genprotimg, pvattest, and pvsecret accept IBM signing key with Armonk as subject locality - zdump/zipl: Support for List-Directed dump from ECKD DASD - zkey: Detect FIPS mode and generate PBKDF for luksFormat according to it * Bug Fixes: - dbginfo.sh: dash compatible copy sequence - rust/pv_core: Fix UvDeviceInfo::get() method - zipl/src: Fix leak of files if run with a broken configuration - zkey: Fix convert command to accept only keys of type CCA-AESDATA * Revendored vendor.tar.gz * Removed obsolete patches - s390-tools-sles15sp5-01-rust-pv-support-Armonk-in-IBM-signing-key-subject.patch - s390-tools-sles15sp6-02-genprotimg-support-Armonk-in-IBM-signing-key-subject.patch - s390-tools-sles15sp6-03-libpv-support-Armonk-in-IBM-signing-key-subject.patch - s390-tools-sles15sp6-04-pvattest-Fix-root-ca-parsing.patch - s390-tools-sles15sp6-genprotimg-makefile.patch OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=219
331 lines
7.0 KiB
Bash
331 lines
7.0 KiB
Bash
#!/bin/bash
|
|
#
|
|
# zfcp_san_disc
|
|
#
|
|
# Outputs a list of zFCP WWPNs or LUNs
|
|
#
|
|
# Usage:
|
|
# zfcp_san_disc [-h | -W | -L -p <WWPN> ] -b <BUS_ID>
|
|
#
|
|
# Return codes
|
|
# 1 zFCP sysfs directory not available
|
|
# 2 Invalid command line parameter
|
|
# 3 Too many commands used
|
|
# 4 Error retrieving HBA list
|
|
# 5 Bus ID not found
|
|
# 6 Error retrieving Port list
|
|
# 7 WWPN not found
|
|
# 8 Bus ID sysfs directory not available
|
|
# 9 WWPN sysfs directory not available/unable to add port to Bus ID
|
|
# 10 Error retrieving LUN list
|
|
# 11 HBA API device not available
|
|
#
|
|
|
|
START_DIR=`pwd`
|
|
SCRIPT_NAME=`basename $0`
|
|
cd `dirname $0`
|
|
SCRIPT_DIR=`pwd`
|
|
cd "${START_DIR}"
|
|
|
|
FCP_SYS_DIR='/sys/bus/ccw/drivers/zfcp'
|
|
|
|
# Commands available
|
|
LIST_WWPN='-W'
|
|
LIST_LUN='-L'
|
|
|
|
COMMAND=''
|
|
BUSID=''
|
|
WWPN=''
|
|
|
|
echo_err()
|
|
{
|
|
echo "$SCRIPT_NAME: $1" 1>&2
|
|
}
|
|
|
|
usage()
|
|
{
|
|
echo "$0 [-h | $LIST_WWPN | $LIST_LUN -p <WWPN>] -b <BUS_ID>" 1>&2
|
|
echo 1>&2
|
|
echo "Commands:" 1>&2
|
|
echo " $LIST_WWPN List WWPNs for the given BUS_ID" 1>&2
|
|
echo " $LIST_LUN List LUNs for the given BUS_ID and WWPN" 1>&2
|
|
echo " -h This usage information" 1>&2
|
|
echo "Options:" 1>&2
|
|
echo " -b BUSID Bus ID to use for listing" 1>&2
|
|
echo " -p WWPN WWPN to use for listing" 1>&2
|
|
}
|
|
|
|
list_lun()
|
|
{
|
|
local PRINT_WWPN
|
|
local BUSID_DIR
|
|
local WWPN_DIR
|
|
local ADDED_PORT
|
|
|
|
}
|
|
|
|
deactivate()
|
|
{
|
|
local ccw=$1
|
|
|
|
echo 0 > /sys/bus/ccw/devices/$ccw/online
|
|
}
|
|
|
|
lun_remove()
|
|
{
|
|
local syspath=$1
|
|
local lun=$2
|
|
|
|
echo "$lun" > $syspath/unit_remove
|
|
}
|
|
|
|
sg_remove()
|
|
{
|
|
local sg=$1
|
|
local sgnum
|
|
|
|
sgnum=${sg#/dev/sg}
|
|
: deactivate /sys/class/scsi_generic/sg$sgnum/device/delete
|
|
echo 1 > /sys/class/scsi_generic/sg$sgnum/device/delete
|
|
udevadm settle
|
|
}
|
|
|
|
while [ $# -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
-b* )
|
|
if [ "$1" == "-b" ]
|
|
then
|
|
shift
|
|
BUSID="$1"
|
|
else
|
|
BUSID="${1:2}"
|
|
fi
|
|
BUSID=`echo $BUSID | tr A-F a-f`
|
|
;;
|
|
-p* )
|
|
if [ "$1" == "-p" ]
|
|
then
|
|
shift
|
|
WWPN="$1"
|
|
else
|
|
WWPN="${1:2}"
|
|
fi
|
|
WWPN=`echo $WWPN | tr A-FX a-fx`
|
|
;;
|
|
"$LIST_WWPN"|"$LIST_LUN" )
|
|
if [ -z "$COMMAND" -o "$1" == "$COMMAND" ]
|
|
then
|
|
COMMAND=$1
|
|
else
|
|
echo_err "You have already specified the $COMMAND command, and cannot use the $1 command also."
|
|
exit 3
|
|
fi
|
|
;;
|
|
-h )
|
|
usage
|
|
exit 0
|
|
;;
|
|
* )
|
|
usage
|
|
echo_err "Unknown command line parameter : $1"
|
|
exit 2
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ -z "$BUSID" ] ; then
|
|
echo_err "No bus ID given"
|
|
exit 2
|
|
fi
|
|
|
|
if [ -z "$COMMAND" ] ; then
|
|
echo_err "Please specify either -W or -L"
|
|
exit 2
|
|
fi
|
|
|
|
if [ ! -d /sys/bus/ccw/devices/$BUSID ] ; then
|
|
echo_err "Unknown bus ID $BUSID"
|
|
exit 2
|
|
fi
|
|
|
|
read devtype < /sys/bus/ccw/devices/$BUSID/devtype
|
|
read cutype < /sys/bus/ccw/devices/$BUSID/cutype
|
|
|
|
if [ "$cutype" != "1731/03" ] ; then
|
|
echo_err "Bus ID $BUSID is not an zfcp adapter"
|
|
exit 2
|
|
fi
|
|
|
|
if [ "$devtype" != "1732/03" -a "$devtype" != "1732/04" ] ; then
|
|
echo_err "Bus ID $BUSID is not an zfcp adapter"
|
|
exit 2
|
|
fi
|
|
|
|
# Now we're sure we're dealing with zfcp devices
|
|
if [ ! -d "$FCP_SYS_DIR" ] ; then
|
|
modprobe zfcp
|
|
fi
|
|
|
|
[ "$COMMAND" == "$LIST_LUN" -a -z "$WWPN" ] && usage && exit 2
|
|
|
|
read online < /sys/bus/ccw/devices/$BUSID/online
|
|
|
|
if [ "$online" != 1 ] ; then
|
|
# Activate adapter
|
|
echo 1 > /sys/bus/ccw/devices/$BUSID/online
|
|
read online < /sys/bus/ccw/devices/$BUSID/online
|
|
|
|
if [ "$online" != 1 ] ; then
|
|
echo_err "Cannot activate zfcp adapter at $BUSID"
|
|
exit 2
|
|
fi
|
|
trapcmd="deactivate $BUSID"
|
|
trap "$trapcmd" EXIT
|
|
fi
|
|
|
|
for loop in 1 2 3 4 5 ; do
|
|
read status < /sys/bus/ccw/devices/$BUSID/status
|
|
(( $status & 0x10000000 )) && break;
|
|
done
|
|
read wwpn_status < /sys/bus/ccw/devices/$BUSID/status
|
|
if !(( $wwpn_status & 0x10000000 )) ; then
|
|
echo_err "Adapter activation failed, status $wwpn_status"
|
|
exit 3
|
|
fi
|
|
|
|
for host in /sys/bus/ccw/devices/$BUSID/host* ; do
|
|
if [ -d $host ] ; then
|
|
hba_num=${host##*host}
|
|
fi
|
|
done
|
|
if [ -z "$hba_num" ] ; then
|
|
echo_err "No SCSI host allocated"
|
|
exit 3
|
|
fi
|
|
|
|
if [ "$COMMAND" == "$LIST_WWPN" ]
|
|
then
|
|
for PRINT_WWPN in /sys/bus/ccw/devices/$BUSID/0x*
|
|
do
|
|
test -d $PRINT_WWPN && echo ${PRINT_WWPN##*/}
|
|
done
|
|
exit 0
|
|
elif [ "$COMMAND" != "$LIST_LUN" ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
ERR=0
|
|
read allow_lun_scan < /sys/module/zfcp/parameters/allow_lun_scan
|
|
if [ "$allow_lun_scan" = "Y" ] ; then
|
|
read port_type < /sys/class/fc_host/host${hba_num}/port_type
|
|
if [ "$port_type" = "NPIV VPORT" ] ; then
|
|
skip_activation=1
|
|
fi
|
|
fi
|
|
if [ -z "$skip_activation" ] ; then
|
|
WWPN_DIR=/sys/bus/ccw/devices/$BUSID/$WWPN
|
|
if [ ! -d "${WWPN_DIR}" ]
|
|
then
|
|
echo_err "port $WWPN not found on zfcp $BUSID"
|
|
exit 9
|
|
fi
|
|
|
|
# Activate WLUN
|
|
if [ ! -d $WWPN_DIR/0xc101000000000000 ] ; then
|
|
echo 0xc101000000000000 > $WWPN_DIR/unit_add
|
|
orig_trapcmd="$trapcmd"
|
|
trapcmd="lun_remove $WWPN_DIR 0xc101000000000000; $trapcmd"
|
|
trap "$trapcmd" EXIT
|
|
activated=1
|
|
|
|
# Wait for udev to catch up
|
|
udevadm settle
|
|
sleep 1
|
|
fi
|
|
# Find corresponding sg device
|
|
sgdev=$(lsscsi -t -g $hba_num:-:-:49409 | sed -n "s/.* fc:$WWPN.* \(\/dev\/sg[0-9]*\)[[:blank:]]*$/\1/p")
|
|
if [ -c "$sgdev" ] ; then
|
|
if sg_luns $sgdev > /dev/null 2>&1 ; then
|
|
LUN_LIST=`sg_luns $sgdev | sed -n 's/^ \(.*\)/\1/p'`
|
|
trapcmd="sg_remove $sgdev; $trapcmd"
|
|
trap "$trapcmd" EXIT
|
|
wlun=1
|
|
else
|
|
wlun=
|
|
fi
|
|
fi
|
|
if [ -z "$wlun" ] ; then
|
|
if [ -n "$activated" ] ; then
|
|
trapcmd=$orig_trapcmd
|
|
trap "$trapcmd" EXIT
|
|
lun_remove $WWPN_DIR 0xc101000000000000
|
|
activated=
|
|
fi
|
|
# Activate LUN 0
|
|
if [ ! -d $WWPN_DIR/0x0000000000000000 ] ; then
|
|
echo 0 > $WWPN_DIR/unit_add
|
|
orig_trapcmd=$trapcmd
|
|
trapcmd="lun_remove $WWPN_DIR 0x0000000000000000; $trapcmd"
|
|
trap "$trapcmd" EXIT
|
|
activated=1
|
|
# Wait for udev to catch up
|
|
udevadm settle
|
|
sleep 1
|
|
fi
|
|
|
|
# Find corresponding sg device
|
|
sgdev=$(lsscsi -t -g $hba_num:-:-:0 | sed -n "s/.* fc:$WWPN.* \(\/dev\/sg[^[:blank:]]*\)[[:blank:]]*$/\1/p")
|
|
if [ -c "$sgdev" ] ; then
|
|
if sg_luns $sgdev > /dev/null 2>&1 ; then
|
|
LUN_LIST=`sg_luns $sgdev | sed -n 's/^ \(.*\)/\1/p'`
|
|
fi
|
|
if [ -n "$activated" ] ; then
|
|
trapcmd="sg_remove $sgdev; $trapcmd"
|
|
trap "$trapcmd" EXIT
|
|
fi
|
|
else
|
|
echo_err "Unable to activate LUN 0"
|
|
trap "$trapcmd" EXIT
|
|
lun_remove $WWPN_DIR 0x0000000000000000
|
|
activated=
|
|
sgdev=
|
|
ERR=10
|
|
fi
|
|
fi
|
|
|
|
for LUN in $LUN_LIST ; do
|
|
echo 0x$LUN
|
|
done
|
|
exit $ERR
|
|
else
|
|
for loop in 1 2 3 4 5 ; do
|
|
if [ -n "$(ls -d /sys/class/fc_remote_ports/rport-${hba_num}:* 2>/dev/null)" ] ; then
|
|
break
|
|
else
|
|
sleep 1
|
|
fi
|
|
done
|
|
|
|
if [ -z "$(ls -d /sys/class/fc_remote_ports/rport-${hba_num}:* 2>/dev/null)" ]; then
|
|
echo "The remote Fiber Channel port has not become available. Exiting"
|
|
exit 1
|
|
fi
|
|
|
|
for rport in /sys/class/fc_remote_ports/rport-${hba_num}:* ; do
|
|
[ -f ${rport}/port_name ] || continue
|
|
read port_name < ${rport}/port_name
|
|
if [ "$port_name" = "$WWPN" ] ; then
|
|
for t in ${rport}/device/target* ; do
|
|
[ -f ${t}/uevent ] || continue
|
|
targetid=${t#*target}
|
|
targetid=${targetid##*:}
|
|
break
|
|
done
|
|
fi
|
|
done
|
|
lsscsi -xx ${hba_num}:0:${targetid}:- | sed -n "s/\[${hba_num}:0:${targetid}:\(0x[0-9a-f]*\)\].*/\1/p"
|
|
fi
|