Skip to content

Commit

Permalink
95zfcp_rules: simplified rd.zfcp commandline for NPIV
Browse files Browse the repository at this point in the history
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 <hare@suse.com>
  • Loading branch information
hreinecke authored and danimo committed Jun 23, 2017
1 parent 5f92325 commit c8aa1d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 8 additions & 1 deletion dracut.cmdline.7.asc
Original file line number Diff line number Diff line change
Expand Up @@ -788,12 +788,19 @@ DASD
ZFCP
~~~~
**rd.zfcp=**__<zfcp adaptor device bus ID>__,__<WWPN>__,__<FCPLUN>__::
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=**__<zfcp adaptor device bus ID>__::
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 <WWPN> and <FCPLUN> parameters can be omitted.
+
[listing]
.Example
--
rd.zfcp=0.0.4000,0x5005076300C213e9,0x5022000000000000
rd.zfcp=0.0.4000
--
**rd.zfcp.conf=0**::
Expand Down
23 changes: 19 additions & 4 deletions modules.d/95zfcp_rules/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]] && {
Expand Down
1 change: 1 addition & 0 deletions modules.d/95zfcp_rules/parse-zfcp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
Expand Down

0 comments on commit c8aa1d9

Please sign in to comment.