From c8aa1d949aecaf146b0a0e1ce269f69e6048dc5a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 10 Mar 2016 15:45:43 +0100 Subject: [PATCH] 95zfcp_rules: simplified rd.zfcp commandline for NPIV When NPIV is enabled and the allow_lun_scan parameter is set to 'Y' the HBA will initiate a LUN scan automatically, so there is no need to specify the WWPN and LUN number manually. References: bsc#964456 Signed-off-by: Hannes Reinecke --- dracut.cmdline.7.asc | 9 ++++++++- modules.d/95zfcp_rules/module-setup.sh | 23 +++++++++++++++++++---- modules.d/95zfcp_rules/parse-zfcp.sh | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc index ba7125c8c6..63c6c10fe2 100644 --- a/dracut.cmdline.7.asc +++ b/dracut.cmdline.7.asc @@ -788,12 +788,19 @@ DASD ZFCP ~~~~ **rd.zfcp=**____,____,____:: - rd.zfcp can be specified multiple times on the kernel command line. + rd.zfcp can be specified multiple times on the kernel command + line. + +**rd.zfcp=**____:: + If NPIV is enabled and the 'allow_lun_scan' parameter to the zfcp + module is set to 'Y' then the zfcp adaptor will be initiating a + scan internally and the and parameters can be omitted. + [listing] .Example -- rd.zfcp=0.0.4000,0x5005076300C213e9,0x5022000000000000 +rd.zfcp=0.0.4000 -- **rd.zfcp.conf=0**:: diff --git a/modules.d/95zfcp_rules/module-setup.sh b/modules.d/95zfcp_rules/module-setup.sh index b9dbd3db88..fc55e69ac2 100755 --- a/modules.d/95zfcp_rules/module-setup.sh +++ b/modules.d/95zfcp_rules/module-setup.sh @@ -5,15 +5,30 @@ cmdline() { is_zfcp() { local _dev=$1 local _devpath=$(cd -P /sys/dev/block/$_dev ; echo $PWD) - local _sdev _lun _wwpn _ccw + local _sdev _scsiid _hostno _lun _wwpn _ccw _port_type + local _allow_lun_scan _is_npiv + _allow_lun_scan=$(cat /sys/module/zfcp/parameters/allow_lun_scan) [ "${_devpath#*/sd}" == "$_devpath" ] && return 1 _sdev="${_devpath%%/block/*}" [ -e ${_sdev}/fcp_lun ] || return 1 - _lun=$(cat ${_sdev}/fcp_lun) - _wwpn=$(cat ${_sdev}/wwpn) + _scsiid="${_sdev##*/}" + _hostno="${_scsiid%%:*}" + [ -d /sys/class/fc_host/host${_hostno} ] || return 1 + _port_type=$(cat /sys/class/fc_host/host${_hostno}/port_type) + case "$_port_type" in + NPIV*) + _is_npiv=1 + ;; + esac _ccw=$(cat ${_sdev}/hba_id) - echo "rd.zfcp=${_ccw},${_wwpn},${_lun}" + if [ "$_is_npiv" ] && [ "$_allow_lun_scan" = "Y" ] ; then + echo "rd.zfcp=${_ccw}" + else + _lun=$(cat ${_sdev}/fcp_lun) + _wwpn=$(cat ${_sdev}/wwpn) + echo "rd.zfcp=${_ccw},${_wwpn},${_lun}" + fi return 0 } [[ $hostonly ]] || [[ $mount_needs ]] && { diff --git a/modules.d/95zfcp_rules/parse-zfcp.sh b/modules.d/95zfcp_rules/parse-zfcp.sh index 2d48716ddc..9fc681debf 100755 --- a/modules.d/95zfcp_rules/parse-zfcp.sh +++ b/modules.d/95zfcp_rules/parse-zfcp.sh @@ -31,6 +31,7 @@ ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="zfcp", IMPORT{program}="collect $c ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1" EOF fi + [ -z "$wwpn" -o -z "$lun" ] && return m=$(sed -n "/.*${wwpn}.*${lun}.*/p" $_rule) if [ -z "$m" ] ; then cat >> $_rule <