From a895d0c8be8a244bbd4211d86b888a3b70f0c12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Wed, 26 Aug 2020 10:49:18 +0200 Subject: [PATCH] - add support for auto LUN scan to zfcpconf.sh (#1552697) --- s390utils.spec | 5 ++++- zfcpconf.sh | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/s390utils.spec b/s390utils.spec index 7f475cb..a9d7600 100644 --- a/s390utils.spec +++ b/s390utils.spec @@ -6,7 +6,7 @@ Name: s390utils Summary: Utilities and daemons for IBM z Systems Version: 2.14.0 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 2 License: MIT ExclusiveArch: s390 s390x @@ -792,6 +792,9 @@ User-space development files for the s390/s390x architecture. %changelog +* Wed Aug 25 2020 Dan Horák - 2:2.14.0-2 +- add support for auto LUN scan to zfcpconf.sh (#1552697) + * Tue Aug 25 2020 Dan Horák - 2:2.14.0-1 - rebased to 2.14.0 diff --git a/zfcpconf.sh b/zfcpconf.sh index 45d10a1..8dc05ad 100644 --- a/zfcpconf.sh +++ b/zfcpconf.sh @@ -2,10 +2,12 @@ # config file syntax: # deviceno WWPN FCPLUN +# deviceno # allowed when auto LUN scan is enabled and port is in NPIV mode # # Example: # 0.0.4000 0x5005076300C213e9 0x5022000000000000 # 0.0.4001 0x5005076300c213e9 0x5023000000000000 +# 0.0.5000 # # # manual setup: @@ -21,6 +23,14 @@ CONFIG=/etc/zfcp.conf PATH=/bin:/sbin +set_online() +{ + DEVICE=$1 + + [ `cat /sys/bus/ccw/drivers/zfcp/${DEVICE}/online` = "0" ] \ + && echo 1 > /sys/bus/ccw/drivers/zfcp/${DEVICE}/online +} + if [ -f "$CONFIG" ]; then if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then modprobe zfcp @@ -34,6 +44,17 @@ if [ -f "$CONFIG" ]; then *) [ -z "$line" ] && continue set $line + if [ $# -eq 1 ]; then + DEVICE=${1##*0x} + if [ `cat /sys/module/zfcp/parameters/allow_lun_scan` = "Y" ]; then + set_online ${DEVICE} + grep -q NPIV /sys/bus/ccw/devices/${DEVICE}/host*/fc_host/host*/port_type || \ + echo "Error: Only device ID (${DEVICE}) given, but port not in NPIV mode" + else + echo "Error: Only device ID (${DEVICE}) given, but LUN scan is disabled for the zfcp module" + fi + continue + fi if [ $# -eq 5 ]; then DEVICE=$1 SCSIID=$2 @@ -46,8 +67,7 @@ if [ -f "$CONFIG" ]; then WWPN=$2 FCPLUN=$3 fi - [ `cat /sys/bus/ccw/drivers/zfcp/${DEVICE}/online` = "0" ] \ - && echo 1 > /sys/bus/ccw/drivers/zfcp/${DEVICE}/online + set_online ${DEVICE} [ ! -d /sys/bus/ccw/drivers/zfcp/${DEVICE}/${WWPN}/${FCPLUN} ] \ && echo $FCPLUN > /sys/bus/ccw/drivers/zfcp/${DEVICE}/${WWPN}/unit_add ;;