mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdev/dracut: add rd.zfcp cmdline option handling
Add parsing of dracut cmdline option "rd.zfcp=..." at initrd runtime. It delegates configuration to chzdev. Implement `dracut --print-cmdline` and `dracut --hostonly-cmdline` for initrd build time. Emit an rd.zfcp option for each zfcp-attached SCSI disk in dracut's device dependency graph (to mount the root-fs, or to access the kdump target). This allows a distribution independent device configuration. Configuration is consistent by using chzdev as backend. It also prevents duplicate activations of the same device. Along with the existing functionality of zdev/dracut, it makes the following dracut modules superfluous: https://github.com/dracutdevs/dracut/tree/master/modules.d/95zfcp [rd.zfcp.conf is no longer needed and thus ignored here; the preceding ("zdev/dracut: fix marking hostonly files so delete option works") makes rd.hostonly=0 work as a generic replacement] https://github.com/dracutdevs/dracut/tree/master/modules.d/95zfcp_rules Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/158 Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com> Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Steffen Maier <maier@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
ed106d7f28
commit
06a30ae529
@@ -25,3 +25,78 @@ zdev_is_kdump() {
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
zdev_zfcp_auto_lun_scan_active() {
|
||||
local _fcpdevsysfs=$1
|
||||
local _porttype _lunscan
|
||||
read -r _porttype < "$_fcpdevsysfs"/host*/fc_host/host*/port_type
|
||||
read -r _lunscan < /sys/module/zfcp/parameters/allow_lun_scan
|
||||
if [[ "$_porttype" == "NPIV VPORT" && "$_lunscan" == "Y" ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# zdev_check_dev() can be extended for other device types such as DASD or PCIe
|
||||
zdev_check_dev() {
|
||||
local _dev=$1
|
||||
local _devsysfs _devtype _subsystem _driver
|
||||
local _intlun _fcplun _scsitarget _wwpn _hbaid
|
||||
_devsysfs=$(
|
||||
cd -P /sys/dev/block/"$_dev" 2> /dev/null && echo "$PWD"
|
||||
)
|
||||
# This is roughly what systemd's udev-builtin-path_id does for zfcp:
|
||||
while [[ -n "$_devsysfs" ]]; do
|
||||
# ascend to parent: strip last path part
|
||||
_devsysfs=${_devsysfs%/*}
|
||||
_subsystem=$(
|
||||
cd -P "$_devsysfs"/subsystem 2> /dev/null && echo "$PWD"
|
||||
)
|
||||
if [[ "${_subsystem##*/}" == "scsi" ]]; then
|
||||
_devtype=$(grep "^DEVTYPE=" "$_devsysfs"/uevent)
|
||||
# check for FCP LUN
|
||||
if [[ "$_devtype" == "DEVTYPE=scsi_device" ]]; then
|
||||
_intlun=${_devsysfs##*:}
|
||||
# convert _intlun to _fcplun [int_to_scsilun()]
|
||||
_fcplun=0
|
||||
((_fcplun |= (_intlun & 0x000000000000ffff) << 48))
|
||||
((_fcplun |= (_intlun & 0x00000000ffff0000) << 16))
|
||||
((_fcplun |= (_intlun & 0x0000ffff00000000) >> 16))
|
||||
((_fcplun |= (_intlun & 0xffff000000000000) >> 48))
|
||||
printf -v _fcplun "0x%016x" "$_fcplun"
|
||||
# bail out if not scsi_transport_fc
|
||||
[[ "${_devsysfs/*rport-*/FOUND}" == "FOUND" ]] || return 0
|
||||
continue
|
||||
fi
|
||||
# check for target WWPN
|
||||
if [[ "$_devtype" == "DEVTYPE=scsi_target" ]]; then
|
||||
_scsitarget=${_devsysfs##*/}
|
||||
read -r _wwpn < "$_devsysfs/fc_transport/$_scsitarget/port_name"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
if [[ "${_subsystem##*/}" == "ccw" ]]; then
|
||||
_driver=$(
|
||||
cd -P "$_devsysfs"/driver 2> /dev/null && echo "$PWD"
|
||||
)
|
||||
# check for FCP device (vHBA) bus-ID
|
||||
if [[ "${_driver##*/}" == "zfcp" ]]; then
|
||||
_hbaid=${_devsysfs##*/}
|
||||
# drop full path and use zfcp auto LUN scan, if:
|
||||
# - not building for kdump which has zfcp auto LUN scan off
|
||||
# - and zfcp auto LUN scan is available
|
||||
if ! zdev_is_kdump && \
|
||||
zdev_zfcp_auto_lun_scan_active "$_devsysfs"; then
|
||||
unset _wwpn
|
||||
unset _fcplun
|
||||
fi
|
||||
if [[ -n "$_wwpn" ]] && [[ -n "$_fcplun" ]]; then
|
||||
printf " rd.zfcp=%s,%s,%s\n" "$_hbaid" "$_wwpn" "$_fcplun"
|
||||
else
|
||||
printf " rd.zfcp=%s\n" "$_hbaid"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user