From 31113165cdb2dca2ccd1b6a822761c8ac0b216fb Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 24 May 2023 19:02:09 +0200 Subject: [PATCH 01/19] refactor(cms): use zdev to simplify handling CMSDASD=... boot option This is just internal to initrd, so we can already migrate the code to consolidated dasd device configuration with zdev https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/. The code change is transparent to users after dracut switch root. Signed-off-by: Steffen Maier --- modules.d/80cms/cmssetup.sh | 108 ++++++-------------------------- modules.d/80cms/module-setup.sh | 3 +- 2 files changed, 21 insertions(+), 90 deletions(-) diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index 68e45632fe..23e81ca983 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -2,34 +2,16 @@ type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh -function sysecho() { - file="$1" - shift - local i=1 - while [ $i -le 10 ]; do - if [ ! -f "$file" ]; then - sleep 1 - i=$((i + 1)) - else - break - fi - done - local status - read -r status < "$file" - if [[ $status != "$*" ]]; then - [ -f "$file" ] && echo "$*" > "$file" - fi -} - function dasd_settle() { - local dasd_status=/sys/bus/ccw/devices/$1/status + local dasd_status + dasd_status=$(lszdev dasd "$1" --columns ATTRPATH:status --no-headings --active) if [ ! -f "$dasd_status" ]; then return 1 fi local i=1 while [ $i -le 60 ]; do local status - read -r status < "$dasd_status" + status=$(lszdev dasd "$1" --columns ATTR:status --no-headings --active) case $status in online | unformatted) return 0 @@ -43,77 +25,23 @@ function dasd_settle() { return 1 } -function dasd_settle_all() { - for dasdccw in $(while read -r line || [ -n "$line" ]; do echo "${line%%(*}"; done < /proc/dasd/devices); do - if ! dasd_settle "$dasdccw"; then - echo $"Could not access DASD $dasdccw in time" - return 1 - fi - done - return 0 -} - -# prints a canonocalized device bus ID for a given devno of any format -function canonicalize_devno() { - case ${#1} in - 3) echo "0.0.0${1}" ;; - 4) echo "0.0.${1}" ;; - *) echo "${1}" ;; - esac - return 0 -} - # read file from CMS and write it to /tmp function readcmsfile() { # $1=dasdport $2=filename local dev - local numcpus local devname local ret=0 if [ $# -ne 2 ]; then return; fi - # precondition: udevd created dasda block device node - if ! dasd_cio_free -d "$1"; then - echo $"DASD $1 could not be cleared from device blacklist" - return 1 - fi - - modprobe dasd_mod dasd="$CMSDASD" - modprobe dasd_eckd_mod - udevadm settle - - # precondition: dasd_eckd_mod driver incl. dependencies loaded, - # dasd_mod must be loaded without setting any DASD online - dev=$(canonicalize_devno "$1") - numcpus=$( - while read -r line || [ -n "$line" ]; do - if strstr "$line" "# processors"; then - echo "${line##*:}" - break - fi - done < /proc/cpuinfo - ) + # precondition: udevd created block device node - if [ "${numcpus}" -eq 1 ]; then - echo 1 > /sys/bus/ccw/devices/"$dev"/online - else - if ! sysecho /sys/bus/ccw/devices/"$dev"/online 1; then - echo $"DASD $dev could not be set online" - return 1 - fi - udevadm settle - if ! dasd_settle "$dev"; then - echo $"Could not access DASD $dev in time" - return 1 - fi + dev="$1" + chzdev --enable --active --yes --quiet --no-root-update --force dasd "$dev" || return 1 + if ! dasd_settle "$dev"; then + echo $"Could not access DASD $dev in time" + return 1 fi - udevadm settle - - devname=$( - cd /sys/bus/ccw/devices/"$dev"/block || exit - set -- * - [ -b /dev/"$1" ] && echo "$1" - ) - devname=${devname:-dasda} + devname=$(lszdev dasd "$dev" --columns NAMES --no-headings --active) + [[ -n $devname ]] || return 1 [[ -d /mnt ]] || mkdir -p /mnt if cmsfs-fuse --to=UTF-8 -a /dev/"$devname" /mnt; then @@ -125,20 +53,22 @@ function readcmsfile() { # $1=dasdport $2=filename ret=1 fi - if ! sysecho /sys/bus/ccw/devices/"$dev"/online 0; then - echo $"DASD $dev could not be set offline again" - #return 1 - fi - udevadm settle + chzdev --disable --active --yes --quiet --no-root-update --force dasd "$dev" # unbind all dasds to unload the dasd modules for a clean start ( cd /sys/bus/ccw/drivers/dasd-eckd || exit - for i in *.*; do echo "$i" > unbind; done + for i in *.*; do echo "$i" > unbind 2> /dev/null; done + ) + ( + cd /sys/bus/ccw/drivers/dasd-fba || exit + for i in *.*; do echo "$i" > unbind 2> /dev/null; done ) udevadm settle modprobe -r dasd_eckd_mod udevadm settle + modprobe -r dasd_fba_mod + udevadm settle modprobe -r dasd_diag_mod udevadm settle modprobe -r dasd_mod diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 2b280e0f37..4872734b12 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -4,6 +4,7 @@ check() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + require_binaries chzdev lszdev || return 1 return 255 } @@ -28,7 +29,7 @@ install() { # shellcheck disable=SC2046 inst_multiple /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \ cmsfs-fuse fusermount bash insmod rmmod cat normalize_dasd_arg sed \ - $(rpm -ql s390utils-base) awk getopt + $(rpm -ql s390utils-base) awk getopt chzdev lszdev inst_libdir_file "gconv/*" #inst /usr/lib/locale/locale-archive From cdd4cce0fc03f4838f53f6f9357a049bb1c501ad Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Sat, 28 Jan 2023 01:58:29 +0100 Subject: [PATCH 02/19] refactor(cms): use consolidated zfcp config with zdev from s390-tools This is just internal to initrd, so we can already migrate the code to consolidated zfcp device configuration with zdev https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/. The code change is transparent to users after dracut switch root. The generated persistent config of chzdev are pure udev rules so it has no dependency on other dracut modules such as zdev, or zfcp. Signed-off-by: Steffen Maier --- modules.d/80cms/cmssetup.sh | 21 ++++++++++++++++----- modules.d/80cms/module-setup.sh | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index 23e81ca983..da42ec0fca 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -117,7 +117,6 @@ processcmsfile() { dasd_cio_free fi - unset _do_zfcp for i in ${!FCP_*}; do echo "${!i}" | while read -r port rest || [ -n "$port" ]; do case $port in @@ -130,12 +129,24 @@ processcmsfile() { port="0.0.$port" ;; esac - echo "$port" "$rest" >> /etc/zfcp.conf + # shellcheck disable=SC2086 + set -- $rest + SAVED_IFS="$IFS" + IFS=":" + # Intentionally do not dynamically activate now, but only generate udev + # rules, which activate the device later during udev coldplug. + if [[ -z $rest ]]; then + chzdev --enable --persistent \ + --no-settle --yes --quiet --no-root-update --force \ + zfcp-host "$port" 2>&1 | vinfo + else + chzdev --enable --persistent \ + --no-settle --yes --quiet --no-root-update --force \ + zfcp-lun "$port:$*" 2>&1 | vinfo + fi + IFS="$SAVED_IFS" done - _do_zfcp=1 done - [[ $_do_zfcp ]] && zfcp_cio_free - unset _do_zfcp } [[ $CMSDASD ]] || CMSDASD=$(getarg "CMSDASD=") diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 4872734b12..0dd86b80d4 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -12,7 +12,7 @@ check() { depends() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - echo znet zfcp dasd dasd_mod bash + echo znet dasd dasd_mod bash return 0 } From 9d0ae68769a2fa3e0d4f79804f3a166c48644b4a Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 24 May 2023 19:04:48 +0200 Subject: [PATCH 03/19] refactor(cms): use consolidated dasd config with zdev from s390-tools Depends on https://github.com/ibm-s390-linux/s390-tools commit 9b2fb1d4d2e2 ("zdev: add helper to convert from dasd_mod.dasd to zdev config"). This is just internal to initrd, so it's possible to migrate the code to consolidated dasd device configuration with zdev https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/. The code change is transparent to users after dracut switch root. The generated persistent config of chzdev are pure udev rules so it has no dependency on other dracut modules such as zdev, dasd, or dasd_mod. Instead now install the corresponding kernel device drivers here directly. Signed-off-by: Steffen Maier --- modules.d/80cms/cmssetup.sh | 6 +++--- modules.d/80cms/module-setup.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index da42ec0fca..01cfd30380 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -1,6 +1,7 @@ #!/bin/bash type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh +type zdev_parse_dasd_list > /dev/null 2>&1 || . /lib/s390-tools/zdev-from-dasd_mod.dasd function dasd_settle() { local dasd_status @@ -112,9 +113,8 @@ processcmsfile() { fi if [[ $DASD ]] && [[ $DASD != "none" ]]; then - echo "$DASD" | normalize_dasd_arg > /etc/dasd.conf - echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf - dasd_cio_free + echo "$DASD" | zdev_parse_dasd_list globals 2>&1 | vinfo + echo "$DASD" | zdev_parse_dasd_list ranges 2>&1 | vinfo fi for i in ${!FCP_*}; do diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 0dd86b80d4..05b049da38 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -12,13 +12,13 @@ check() { depends() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - echo znet dasd dasd_mod bash + echo znet bash return 0 } # called by dracut installkernel() { - instmods zfcp + instmods zfcp dasd_mod dasd_eckd_mod dasd_fba_mod dasd_diag_mod } # called by dracut @@ -28,7 +28,7 @@ install() { inst_script "$moddir/cmsifup.sh" /sbin/cmsifup # shellcheck disable=SC2046 inst_multiple /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \ - cmsfs-fuse fusermount bash insmod rmmod cat normalize_dasd_arg sed \ + cmsfs-fuse fusermount bash insmod rmmod cat /lib/s390-tools/zdev-from-dasd_mod.dasd sed \ $(rpm -ql s390utils-base) awk getopt chzdev lszdev inst_libdir_file "gconv/*" From 680b7f500ddbdc4775ad644ee4972e72054a1f14 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 26 Jul 2023 13:50:03 +0200 Subject: [PATCH 04/19] refactor(cms): use consolidated network config with zdev from s390-tools This is just internal to initrd, so we can already migrate the code to consolidated network device configuration with zdev https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/. The code change is transparent to users after dracut switch root. The generated persistent config of chzdev are pure udev rules so it has no dependency on the zdev dracut module. Keep the dependency on dracut module znet to at least pull in the required kernel device drivers. Since consolidated s390 network device configuration with zdev is used, it takes care of all s390-specific settings. None of the s390-specific ifcfg variables should be used anymore. NETTYPE, OPTIONS, PORTNAME, and CTCPROT can be removed entirely. SUBCHANNELS is kept because there are some dependency chains (probably around the key identifiying an interface which is not HWADDR): modules.d/35network-legacy/module-setup.sh parses (sources) each of /etc/sysconfig/network-scripts/ifcfg-* and if that contains SUBCHANNELS, create a symlink from the ifcfg file to /etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf modules.d/35network-legacy/ifup.sh installed as /sbin/ifup checks during team setup if a slave interface is an s390 channel-attached network interface and then parses (sources) /etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf from above, if that file exists Signed-off-by: Steffen Maier --- modules.d/80cms/cms-write-ifcfg.sh | 13 ------------- modules.d/80cms/cmssetup.sh | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/modules.d/80cms/cms-write-ifcfg.sh b/modules.d/80cms/cms-write-ifcfg.sh index ecfd53efb0..9126309212 100755 --- a/modules.d/80cms/cms-write-ifcfg.sh +++ b/modules.d/80cms/cms-write-ifcfg.sh @@ -81,21 +81,8 @@ EOF fi # colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf [[ $SEARCHDNS ]] && echo "DOMAIN=\"$SEARCHDNS\"" >> "$IFCFGFILE" - [[ $NETTYPE ]] && echo "NETTYPE=$NETTYPE" >> "$IFCFGFILE" [[ $PEERID ]] && echo "PEERID=$PEERID" >> "$IFCFGFILE" - [[ $PORTNAME ]] && echo "PORTNAME=$PORTNAME" >> "$IFCFGFILE" - [[ $CTCPROT ]] && echo "CTCPROT=$CTCPROT" >> "$IFCFGFILE" [[ $MACADDR ]] && echo "MACADDR=$MACADDR" >> "$IFCFGFILE" - optstr="" - for option in LAYER2 PORTNO; do - [ -z "${!option}" ] && continue - [ -n "$optstr" ] && optstr=${optstr}" " - optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option} - done - # write single quotes since network.py removes double quotes but we need quotes - echo "OPTIONS='$optstr'" >> "$IFCFGFILE" - unset option - unset optstr unset DNS1 unset DNS2 echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index 01cfd30380..5e5b926718 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -82,13 +82,19 @@ processcmsfile() { SUBCHANNELS="$(echo "$SUBCHANNELS" | sed 'y/ABCDEF/abcdef/')" if [[ $NETTYPE ]]; then - ( - echo -n "$NETTYPE","$SUBCHANNELS" - [[ $PORTNAME ]] && echo -n ",portname=$PORTNAME" - [[ $LAYER2 ]] && echo -n ",layer2=$LAYER2" - [[ $NETTYPE == "ctc" ]] && [[ $CTCPROT ]] && echo -n ",protocol=$CTCPROT" - echo - ) >> /etc/ccw.conf + _cms_attrs="" + if [[ $PORTNAME ]]; then + if [[ $NETTYPE == lcs ]]; then + _cms_attrs="$_cms_attrs portno=$PORTNAME" + else + _cms_attrs="$_cms_attrs portname=$PORTNAME" + fi + fi + [[ $LAYER2 ]] && _cms_attrs="$_cms_attrs layer2=$LAYER2" + [[ $CTCPROT ]] && _cms_attrs="$_cms_attrs protocol=$CTCPROT" + # shellcheck disable=SC2086 + chzdev --enable --persistent --yes --no-root-update --force \ + "$NETTYPE" "$SUBCHANNELS" $_cms_attrs 2>&1 | vinfo OLDIFS=$IFS IFS=, @@ -109,7 +115,6 @@ processcmsfile() { [[ -f /etc/udev/rules.d/90-net.rules ]] \ || printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$name source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules udevadm control --reload - znet_cio_free fi if [[ $DASD ]] && [[ $DASD != "none" ]]; then From d71591f8df992549a54ea4cb56b7611ee59295d7 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 8 Feb 2024 18:38:48 +0100 Subject: [PATCH 05/19] refactor(cms): remove now unnecessary inclusion of full s390utils-base Signed-off-by: Steffen Maier --- modules.d/80cms/module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 05b049da38..5b33cd1806 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -29,7 +29,7 @@ install() { # shellcheck disable=SC2046 inst_multiple /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \ cmsfs-fuse fusermount bash insmod rmmod cat /lib/s390-tools/zdev-from-dasd_mod.dasd sed \ - $(rpm -ql s390utils-base) awk getopt chzdev lszdev + awk getopt chzdev lszdev inst_libdir_file "gconv/*" #inst /usr/lib/locale/locale-archive From 5fe5c7ebd60ff401568f3ac3a598eadd1b50222d Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 20 Jan 2023 18:22:19 +0100 Subject: [PATCH 06/19] feat(zfcp_rules): remove zfcp handling consolidated in s390-tools These are handled by s390-tools zdev dracut module 95zdev as of https://github.com/ibm-s390-linux/s390-tools/commit/06a30ae529a5d6ad2369ed81da056bf3a6147bb6 ("zdev/dracut: add rd.zfcp cmdline option handling"). Even though this removes one implementation of parsing rd.zfcp in dracut, above s390-tools change introduces another implementation of parsing the exact same rd.zfcp syntax. Therefore, it would be good to keep the documentation in man/dracut.cmdline.7 of dracut as one central place describing all s390 device types that dracut handles. This also fixes problems such as RHBZ 1552619/1745470. It was due to a duplicate configuration because the SUSE-specific module 95zfcp_rules does not have any distro-specific dependency and thus also ran in Red Hat distros. That also caused a kind of competition with 95zfcp regarding the same hook registration: inst_hook cmdline 30 "$moddir/parse-zfcp.sh" "luckily" 95zfcp wins since it runs lexicographically first and the first one registering the hook via inst_simple wins. Because commit c8aa1d949aec ("95zfcp_rules: simplified rd.zfcp commandline for NPIV") extended the emitted rd.zfcp syntax for hostonly-cmdline in 95zfcp_rules, kdump initrds built with hostonly-cmdline parsed such rd.zfcp with 95zfcp, which did not understand the extended syntax yet and aborted early boot with a syntax error. It also seems that parse-zfcp.sh on its own is without effect because create_udev_rule() [similar to what zfcp_disk_configure had generated] does not handle the pre-requisite of setting an FCP device (vHBA) online first. So the rport match does not trigger unless something else happens to set an FCP device online [such as rules generated by zfcp_host_configure]. Related to commit d40c49a8dfe2 ("fix(zfcp_rules): remove collect based udev rule creators"). module-setup.sh having copied all udev rules from the root-fs into the initrd conflicted with s390-tools dracut module zdev-kdump, which intentionally only activates the dependencies of the kdump target. Signed-off-by: Steffen Maier --- .github/labeler.yml | 4 -- modules.d/95zfcp_rules/module-setup.sh | 80 -------------------------- modules.d/95zfcp_rules/parse-zfcp.sh | 74 ------------------------ 3 files changed, 158 deletions(-) delete mode 100755 modules.d/95zfcp_rules/module-setup.sh delete mode 100755 modules.d/95zfcp_rules/parse-zfcp.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index 5667c63571..bec706dfb8 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -462,10 +462,6 @@ zfcp: - changed-files: - any-glob-to-any-file: 'modules.d/95zfcp/*' -zfcp_rules: - - changed-files: - - any-glob-to-any-file: 'modules.d/95zfcp_rules/*' - znet: - changed-files: - any-glob-to-any-file: 'modules.d/95znet/*' diff --git a/modules.d/95zfcp_rules/module-setup.sh b/modules.d/95zfcp_rules/module-setup.sh deleted file mode 100755 index dfa795146d..0000000000 --- a/modules.d/95zfcp_rules/module-setup.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -# called by dracut -cmdline() { - is_zfcp() { - local _dev=$1 - local _devpath - _devpath=$( - cd -P /sys/dev/block/"$_dev" || exit - echo "$PWD" - ) - local _sdev _scsiid _hostno _lun _wwpn _ccw _port_type - local _allow_lun_scan _is_npiv - - read -r _allow_lun_scan < /sys/module/zfcp/parameters/allow_lun_scan - [ "${_devpath#*/sd}" == "$_devpath" ] && return 1 - _sdev="${_devpath%%/block/*}" - [ -e "${_sdev}"/fcp_lun ] || return 1 - _scsiid="${_sdev##*/}" - _hostno="${_scsiid%%:*}" - [ -d /sys/class/fc_host/host"${_hostno}" ] || return 1 - read -r _port_type < /sys/class/fc_host/host"${_hostno}"/port_type - case "$_port_type" in - NPIV*) - _is_npiv=1 - ;; - esac - read -r _ccw < "${_sdev}"/hba_id - if [ "$_is_npiv" ] && [ "$_allow_lun_scan" = "Y" ]; then - echo "rd.zfcp=${_ccw}" - else - read -r _lun < "${_sdev}"/fcp_lun - read -r _wwpn < "${_sdev}"/wwpn - echo "rd.zfcp=${_ccw},${_wwpn},${_lun}" - fi - return 0 - } - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves_all is_zfcp - } | sort | uniq -} - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - local _ccw - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - - [[ $hostonly ]] || [[ $mount_needs ]] && { - found=0 - for _ccw in /sys/bus/ccw/devices/*/host*; do - [ -d "$_ccw" ] || continue - found=$((found + 1)) - done - [ $found -eq 0 ] && return 255 - } - return 0 -} - -# called by dracut -depends() { - echo bash - return 0 -} - -# called by dracut -install() { - inst_hook cmdline 30 "$moddir/parse-zfcp.sh" - if [[ $hostonly_cmdline == "yes" ]]; then - local _zfcp - - for _zfcp in $(cmdline); do - printf "%s\n" "$_zfcp" >> "${initdir}/etc/cmdline.d/94zfcp.conf" - done - fi - if [[ $hostonly ]]; then - inst_rules_wildcard "51-zfcp-*.rules" - inst_rules_wildcard "41-zfcp-*.rules" - fi -} diff --git a/modules.d/95zfcp_rules/parse-zfcp.sh b/modules.d/95zfcp_rules/parse-zfcp.sh deleted file mode 100755 index a474b81b07..0000000000 --- a/modules.d/95zfcp_rules/parse-zfcp.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -create_udev_rule() { - local ccw=$1 - local wwpn=$2 - local lun=$3 - local _rule=/etc/udev/rules.d/51-zfcp-${ccw}.rules - local _cu_type _dev_type - - if [ -x /sbin/cio_ignore ] && cio_ignore -i "$ccw" > /dev/null; then - cio_ignore -r "$ccw" - fi - - if [ -e /sys/bus/ccw/devices/"${ccw}" ]; then - read -r _cu_type < /sys/bus/ccw/devices/"${ccw}"/cutype - read -r _dev_type < /sys/bus/ccw/devices/"${ccw}"/devtype - fi - if [ "$_cu_type" != "1731/03" ]; then - return 0 - fi - if [ "$_dev_type" != "1732/03" ] && [ "$_dev_type" != "1732/04" ]; then - return 0 - fi - - [ -z "$wwpn" ] || [ -z "$lun" ] && return - m=$(sed -n "/.*${wwpn}.*${lun}.*/p" "$_rule") - if [ -z "$m" ]; then - cat >> "$_rule" << EOF -ACTION=="add", KERNEL=="rport-*", ATTR{port_name}=="$wwpn", SUBSYSTEMS=="ccw", KERNELS=="$ccw", ATTR{[ccw/$ccw]$wwpn/unit_add}="$lun" -EOF - fi -} - -if [[ -f /sys/firmware/ipl/ipl_type ]] \ - && [[ $(< /sys/firmware/ipl/ipl_type) == "fcp" ]]; then - ( - read -r _wwpn < /sys/firmware/ipl/wwpn - read -r _lun < /sys/firmware/ipl/lun - read -r _ccw < /sys/firmware/ipl/device - - create_udev_rule "$_ccw" "$_wwpn" "$_lun" - ) -fi - -for zfcp_arg in $(getargs rd.zfcp); do - ( - OLDIFS="$IFS" - IFS="," - # shellcheck disable=SC2086 - set $zfcp_arg - IFS="$OLDIFS" - create_udev_rule "$1" "$2" "$3" - ) -done - -for zfcp_arg in $(getargs root=) $(getargs resume=); do - ( - case $zfcp_arg in - /dev/disk/by-path/ccw-*) - ccw_arg=${zfcp_arg##*/} - ;; - esac - if [ -n "$ccw_arg" ]; then - OLDIFS="$IFS" - IFS="-" - # shellcheck disable=SC2086 - set -- $ccw_arg - IFS="$OLDIFS" - _wwpn=${4%:*} - _lun=${4#*:} - create_udev_rule "$2" "$wwpn" "$lun" - fi - ) -done From f084b0b93b23c1dae64f4499110c9299f3086084 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Tue, 31 Jan 2023 09:14:40 +0100 Subject: [PATCH 07/19] feat(zfcp): minimize zfcp handling consolidated in s390-tools Parsing of rd.zfcp is handled by s390-tools zdev dracut module 95zdev as of https://github.com/ibm-s390-linux/s390-tools/commit/06a30ae529a5d6ad2369ed81da056bf3a6147bb6 ("zdev/dracut: add rd.zfcp cmdline option handling"). Even though this removes the last implementation of parsing rd.zfcp in dracut, above s390-tools change introduces another implementation of parsing the exact same rd.zfcp syntax. Therefore, it would be good to keep the documentation in man/dracut.cmdline.7 of dracut as one central place describing all s390 device types that dracut handles. For the time being, keep copying /etc/zfcp.conf. Retain the call of zfcp_cio_free so /etc/zfcp.conf gets processed even with the typical cio_ignore kernel boot parameter ignoring most devices. Also keep handling rd.zfcp.conf=0 so users can, at boot time, ignore /etc/zfcp.conf already copied into initrd. Preparation for consolidating persistent configuration with zdev. Signed-off-by: Steffen Maier --- man/dracut.cmdline.7.asc | 12 +++++++++++- modules.d/95zfcp/module-setup.sh | 4 ++-- modules.d/95zfcp/parse-zfcp.sh | 11 ----------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc index fefa2092c7..b03aa2de83 100644 --- a/man/dracut.cmdline.7.asc +++ b/man/dracut.cmdline.7.asc @@ -979,12 +979,22 @@ ZFCP **rd.zfcp=**____,____,____:: rd.zfcp can be specified multiple times on the kernel command line. ++ +NOTE: + This parameter is no longer handled by dracut itself but with the exact + same syntax by + https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/dracut/95zdev. **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 + module is set to 'Y' then the zfcp driver will be initiating a scan internally and the and parameters can be omitted. + +NOTE: + This parameter is no longer handled by dracut itself but with the exact + same syntax by + https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/dracut/95zdev. ++ [listing] .Example -- diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh index e1f3aa35a0..b547f9bc14 100755 --- a/modules.d/95zfcp/module-setup.sh +++ b/modules.d/95zfcp/module-setup.sh @@ -5,7 +5,7 @@ check() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - require_binaries zfcp_cio_free grep sed seq || return 1 + require_binaries zfcp_cio_free sed || return 1 return 0 } @@ -23,7 +23,7 @@ installkernel() { # called by dracut install() { inst_hook cmdline 30 "$moddir/parse-zfcp.sh" - inst_multiple zfcp_cio_free grep sed seq + inst_multiple zfcp_cio_free sed inst_script /sbin/zfcpconf.sh inst_rules 56-zfcp.rules diff --git a/modules.d/95zfcp/parse-zfcp.sh b/modules.d/95zfcp/parse-zfcp.sh index 495aa67fd0..41216dd960 100755 --- a/modules.d/95zfcp/parse-zfcp.sh +++ b/modules.d/95zfcp/parse-zfcp.sh @@ -2,15 +2,4 @@ getargbool 1 rd.zfcp.conf -d -n rd_NO_ZFCPCONF || rm /etc/zfcp.conf -for zfcp_arg in $(getargs rd.zfcp -d 'rd_ZFCP='); do - echo "$zfcp_arg" | grep '^0\.[0-9a-fA-F]\.[0-9a-fA-F]\{4\}\(,0x[0-9a-fA-F]\{16\},0x[0-9a-fA-F]\{16\}\)\?$' > /dev/null - test $? -ne 0 && die "For argument 'rd.zfcp=$zfcp_arg'\nSorry, invalid format." - ( - IFS="," - # shellcheck disable=SC2086 - set $zfcp_arg - echo "$@" >> /etc/zfcp.conf - ) -done - zfcp_cio_free From 9b4ef02843247b615b5f0c5d262290d1e470955d Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 23 Mar 2023 18:06:23 +0100 Subject: [PATCH 08/19] feat(dasd_rules): remove dasd handling consolidated in s390-tools These are handled by s390-tools zdev dracut module 95zdev as of https://github.com/ibm-s390-linux/s390-tools/commit/99270236805972544932feab9692ee7122a343b8 ("zdev/dracut: add rd.dasd cmdline option handling"). Even though this removes one implementation of parsing rd.dasd in dracut, above s390-tools change introduces another implementation of parsing the exact same rd.dasd syntax. Therefore, it would be good to keep the documentation in man/dracut.cmdline.7 of dracut as one central place describing all s390 device types that dracut handles. module-setup.sh having copied all udev rules from the root-fs into the initrd conflicted with s390-tools dracut module zdev-kdump, which intentionally only activates the dependencies of the kdump target. Signed-off-by: Steffen Maier --- .github/labeler.yml | 4 -- modules.d/95dasd_rules/module-setup.sh | 65 -------------------------- modules.d/95dasd_rules/parse-dasd.sh | 43 ----------------- 3 files changed, 112 deletions(-) delete mode 100755 modules.d/95dasd_rules/module-setup.sh delete mode 100755 modules.d/95dasd_rules/parse-dasd.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index bec706dfb8..19b05e182f 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -382,10 +382,6 @@ dasd_mod: - changed-files: - any-glob-to-any-file: 'modules.d/95dasd_mod/*' -dasd_rules: - - changed-files: - - any-glob-to-any-file: 'modules.d/95dasd_rules/*' - dcssblk: - changed-files: - any-glob-to-any-file: 'modules.d/95dcssblk/*' diff --git a/modules.d/95dasd_rules/module-setup.sh b/modules.d/95dasd_rules/module-setup.sh deleted file mode 100755 index 06c57a48eb..0000000000 --- a/modules.d/95dasd_rules/module-setup.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -# called by dracut -cmdline() { - is_dasd() { - local _dev=$1 - local _devpath - _devpath=$( - cd -P /sys/dev/block/"$_dev" || exit - echo "$PWD" - ) - - [ "${_devpath#*/dasd}" == "$_devpath" ] && return 1 - _ccw="${_devpath%%/block/*}" - echo "rd.dasd=${_ccw##*/}" - return 0 - } - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves_all is_dasd || return 255 - } | sort | uniq -} - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - local found=0 - local bdev - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - - [[ $hostonly ]] || [[ $mount_needs ]] && { - for bdev in /sys/block/*; do - case "${bdev##*/}" in - dasd*) - found=$((found + 1)) - break - ;; - esac - done - [ $found -eq 0 ] && return 255 - } - return 0 -} - -# called by dracut -depends() { - echo 'dasd_mod' bash - return 0 -} - -# called by dracut -install() { - inst_hook cmdline 30 "$moddir/parse-dasd.sh" - if [[ $hostonly_cmdline == "yes" ]]; then - local _dasd - _dasd=$(cmdline) - [[ $_dasd ]] && printf "%s\n" "$_dasd" >> "${initdir}/etc/cmdline.d/95dasd.conf" - fi - if [[ $hostonly ]]; then - inst_rules_wildcard "51-dasd-*.rules" - inst_rules_wildcard "41-dasd-*.rules" - mark_hostonly /etc/udev/rules.d/51-dasd-*.rules - mark_hostonly /etc/udev/rules.d/41-dasd-*.rules - fi - inst_rules 59-dasd.rules -} diff --git a/modules.d/95dasd_rules/parse-dasd.sh b/modules.d/95dasd_rules/parse-dasd.sh deleted file mode 100755 index 4454aec3e3..0000000000 --- a/modules.d/95dasd_rules/parse-dasd.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -allow_device() { - local ccw=$1 - - if [ -x /sbin/cio_ignore ] && cio_ignore -i "$ccw" > /dev/null; then - cio_ignore -r "$ccw" - fi -} - -if [[ -f /sys/firmware/ipl/ipl_type ]] && [[ $(< /sys/firmware/ipl/ipl_type) == "ccw" ]]; then - allow_device "$(< /sys/firmware/ipl/device)" -fi - -for dasd_arg in $(getargs root=) $(getargs resume=); do - [[ $dasd_arg =~ /dev/disk/by-path/ccw-* ]] || continue - - ccw_dev="${dasd_arg##*/ccw-}" - allow_device "${ccw_dev%%-*}" -done - -for dasd_arg in $(getargs rd.dasd=); do - IFS=',' read -r -a devs <<< "$dasd_arg" - declare -p devs - for dev in "${devs[@]}"; do - case "$dev" in - autodetect | probeonly) ;; - - *-*) - IFS="-" read -r start end _ <<< "${dev%(ro)}" - prefix=${start%.*} - start=${start##*.} - for rdev in $(seq $((16#$start)) $((16#$end))); do - allow_device "$(printf "%s.%04x" "$prefix" "$rdev")" - done - ;; - *) - IFS="." read -r sid ssid chan _ <<< "${dev%(ro)}" - allow_device "$(printf "%01x.%01x.%04x" $((16#$sid)) $((16#$ssid)) $((16#$chan)))" - ;; - esac - done -done From 08686015c4f5359f67c9bbfd1f3ccec2efebd652 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 23 Mar 2023 18:22:56 +0100 Subject: [PATCH 09/19] feat(dasd_mod): minimize dasd handling consolidated in s390-tools Parsing of rd.dasd is handled by s390-tools zdev dracut module 95zdev as of https://github.com/ibm-s390-linux/s390-tools/commit/99270236805972544932feab9692ee7122a343b8 ("zdev/dracut: add rd.dasd cmdline option handling"). Even though this removes one implementation of parsing rd.dasd in dracut, above s390-tools change introduces another implementation of parsing the exact same rd.dasd syntax. Therefore, it would be good to keep the documentation in man/dracut.cmdline.7 of dracut as one central place describing all s390 device types that dracut handles. 95dasd/modules-setup.sh copies /etc/dasd.conf from root-fs into initrd. Retain the call of dasd_cio_free here so /etc/dasd.conf gets processed even with the typical cio_ignore kernel boot parameter ignoring most devices. Preparation for consolidating persistent configuration with zdev. Signed-off-by: Steffen Maier --- modules.d/95dasd_mod/module-setup.sh | 2 -- modules.d/95dasd_mod/parse-dasd-mod.sh | 14 -------------- 2 files changed, 16 deletions(-) diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh index c59dd3acee..155eaacc71 100755 --- a/modules.d/95dasd_mod/module-setup.sh +++ b/modules.d/95dasd_mod/module-setup.sh @@ -4,7 +4,6 @@ check() { local _arch=${DRACUT_ARCH:-$(uname -m)} [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - require_binaries grep sed seq return 0 } @@ -22,6 +21,5 @@ installkernel() { # called by dracut install() { inst_hook cmdline 31 "$moddir/parse-dasd-mod.sh" - inst_multiple grep sed seq inst_multiple -o dasd_cio_free } diff --git a/modules.d/95dasd_mod/parse-dasd-mod.sh b/modules.d/95dasd_mod/parse-dasd-mod.sh index 2b86d45434..b635ecf9c2 100755 --- a/modules.d/95dasd_mod/parse-dasd-mod.sh +++ b/modules.d/95dasd_mod/parse-dasd-mod.sh @@ -1,18 +1,4 @@ #!/bin/sh -mod_args="" - -for dasd_arg in $(getargs rd.dasd= -d rd_DASD= DASD=); do - mod_args="$mod_args,$dasd_arg" -done - -mod_args="${mod_args#*,}" - -if [ -x /sbin/dasd_cio_free -a -n "$mod_args" ]; then - [ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d - echo "options dasd_mod dasd=$mod_args" >> /etc/modprobe.d/dasd_mod.conf -fi - -unset dasd_arg if [ -x /sbin/dasd_cio_free ]; then dasd_cio_free fi From 660dbfb895fbf368712ed48fccbb4d4952ec7380 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 23 Mar 2023 19:33:52 +0100 Subject: [PATCH 10/19] feat(dasd): minimize dasd handling consolidated in s390-tools Parsing of rd.dasd is handled by s390-tools zdev dracut module 95zdev as of https://github.com/ibm-s390-linux/s390-tools/commit/99270236805972544932feab9692ee7122a343b8 ("zdev/dracut: add rd.dasd cmdline option handling"). Even though this removes the last implementation of parsing rd.dasd in dracut, above s390-tools change introduces another implementation of parsing the exact same rd.dasd syntax. Therefore, it would be good to keep the documentation in man/dracut.cmdline.7 of dracut as one central place describing all s390 device types that dracut handles. For the time being, keep copying /etc/dasd.conf. The corresponding call to dasd_cio_free is in 95dasd_mod/parse-dasd-mod.sh and indirectly triggers processing of /etc/dasd.conf even with the typical cio_ignore kernel boot parameter ignoring most devices. Preparation for consolidating persistent configuration with zdev. Signed-off-by: Steffen Maier --- man/dracut.cmdline.7.asc | 11 ++++++++++- modules.d/95dasd/module-setup.sh | 6 ++---- modules.d/95dasd/parse-dasd.sh | 11 ----------- 3 files changed, 12 insertions(+), 16 deletions(-) delete mode 100755 modules.d/95dasd/parse-dasd.sh diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc index b03aa2de83..21c8cda960 100644 --- a/man/dracut.cmdline.7.asc +++ b/man/dracut.cmdline.7.asc @@ -972,7 +972,16 @@ root=virtiofs:host rw DASD ~~~~ **rd.dasd=**....:: - same syntax as the kernel module parameter (s390 only) + same syntax as the kernel module parameter (s390 only). + For more details on the syntax see the IBM book + "Linux on IBM Z and IBM LinuxONE - Device Drivers, Features, and Commands" + https://www.ibm.com/docs/en/linux-on-systems?topic=overview-device-drivers-features-commands. + This parameter can be specified multiple times. ++ +NOTE: + This parameter is no longer handled by dracut itself but with the exact + same syntax by + https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/dracut/95zdev. ZFCP ~~~~ diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh index 180da1406c..825f95d810 100755 --- a/modules.d/95dasd/module-setup.sh +++ b/modules.d/95dasd/module-setup.sh @@ -4,20 +4,18 @@ check() { local _arch=${DRACUT_ARCH:-$(uname -m)} [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - require_binaries normalize_dasd_arg || return 1 + require_binaries dasdconf.sh || return 1 return 0 } # called by dracut depends() { - echo "dasd_mod" return 0 } # called by dracut install() { - inst_hook cmdline 30 "$moddir/parse-dasd.sh" - inst_multiple dasdinfo dasdconf.sh normalize_dasd_arg + inst_multiple dasdconf.sh conf=/etc/dasd.conf if [[ $hostonly && -f $conf ]]; then inst -H $conf diff --git a/modules.d/95dasd/parse-dasd.sh b/modules.d/95dasd/parse-dasd.sh deleted file mode 100755 index cda3970c5b..0000000000 --- a/modules.d/95dasd/parse-dasd.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -for dasd_arg in $(getargs rd.dasd= -d rd_DASD= DASD=); do - ( - local OLDIFS="$IFS" - IFS="," - # shellcheck disable=SC2086 - set -- $dasd_arg - IFS="$OLDIFS" - echo "$@" | normalize_dasd_arg >> /etc/dasd.conf - ) -done From fdddfddc6fa11b4efe6fe47ca4a932a57aa6808d Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Tue, 25 Jul 2023 19:43:05 +0200 Subject: [PATCH 11/19] feat(znet): use zdev for consolidated device configuration Remove any distribution-specifics from s390 channel-attached network device configuration. Similar to 95qeth_rules, copy the existing persistent network configuration into the initrd. This needs to go via chzdev import so chzdev updates (adds to) the cio_ignore persistent config inside the initrd, because other dracut modules such as zdev from s390-tools also import persistent (non-network) config into initrd and the set union of devices needs to end up in the cio_ignore persistent config inside the initrd. Additional debugging output can be generated with e.g. dracut option "--stdlog 5" (or short -L5). It shows the chzdev export result, the output of chzdev imports, and an overview of the resulting persistent config within the initrd. Typically combined with "--debug" to get a shell trace from building an initrd (Note: --debug does not increase the log levels). Note that nm-initrd-generator also parses rd.znet and rd.znet_ifname to fill in s390 options of a NetworkManager connection definition. Signed-off-by: Steffen Maier --- modules.d/95znet/module-setup.sh | 37 +++++++++++++++++++++++-- modules.d/95znet/parse-ccw.sh | 47 ++++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh index df37c66089..95164bba64 100755 --- a/modules.d/95znet/module-setup.sh +++ b/modules.d/95znet/module-setup.sh @@ -5,7 +5,7 @@ check() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - require_binaries znet_cio_free grep sed seq readlink || return 1 + require_binaries grep sed seq readlink chzdev || return 1 return 0 } @@ -24,6 +24,37 @@ installkernel() { # called by dracut install() { inst_hook cmdline 30 "$moddir/parse-ccw.sh" - inst_rules 81-ccw.rules - inst_multiple znet_cio_free grep sed seq readlink /lib/udev/ccw_init + inst_multiple grep sed seq readlink chzdev + if [[ $hostonly ]]; then + local _tempfile + _tempfile=$(mktemp --tmpdir="${DRACUT_TMPDIR}" dracut-zdev.XXXXXX) + { + chzdev qeth --export - --configured --persistent --quiet --type + chzdev lcs --export - --configured --persistent --quiet --type + chzdev ctc --export - --configured --persistent --quiet --type + } 2> /dev/null > "$_tempfile" + ddebug < "$_tempfile" + chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ + --yes --no-root-update --force 2>&1 | ddebug + lszdev --configured --persistent --info \ + --base "/etc=$initdir/etc" 2>&1 | ddebug + rm -f "$_tempfile" + # these are purely generated udev rules so we have to glob expand + # within $initdir and strip the $initdir prefix for mark_hostonly + local -a _array + # shellcheck disable=SC2155 + local _nullglob=$(shopt -p nullglob) + shopt -u nullglob + # shellcheck disable=SC2086 + readarray -t _array < <( + ls -1 $initdir/etc/udev/rules.d/41-*.rules 2> /dev/null + ) + [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" + # shellcheck disable=SC2086 + readarray -t _array < <( + ls -1 $initdir/etc/modprobe.d/s390x-*.conf 2> /dev/null + ) + [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" + $_nullglob + fi } diff --git a/modules.d/95znet/parse-ccw.sh b/modules.d/95znet/parse-ccw.sh index d89536059f..aacc988e4e 100755 --- a/modules.d/95znet/parse-ccw.sh +++ b/modules.d/95znet/parse-ccw.sh @@ -1,7 +1,50 @@ #!/bin/bash +znet_base_args="--no-settle --yes --no-root-update --force" + +# at this point in time dracut's vinfo() only logs to journal which is hard for +# s390 users to find and access on a line mode console such as 3215 mode +# so use a vinfo alternative that still prints to the console via kmsg +znet_vinfo() { + while read -r _znet_vinfo_line || [ -n "$_znet_vinfo_line" ]; do + # Prefix "<30>" represents facility LOG_DAEMON 3 and loglevel INFO 6: + # (facility << 3) | level. + echo "<30>dracut: $_znet_vinfo_line" > /dev/kmsg + done +} + for ccw_arg in $(getargs rd.ccw -d 'rd_CCW=') $(getargs rd.znet -d 'rd_ZNET='); do - echo "$ccw_arg" >> /etc/ccw.conf + ( + SAVED_IFS="$IFS" + IFS="," + # shellcheck disable=SC2086 + set -- $ccw_arg + IFS="$SAVED_IFS" + type="$1" + subchannel1="$2" + subchannel2="$3" + subchannel3="$4" + echo "rd.znet ${ccw_arg} :" | znet_vinfo + if [ "$#" -lt 3 ]; then + echo "rd.znet needs at least 3 list items: type,subchannel1,subchannel2" | znet_vinfo + fi + if [ "$1" = "qeth" ]; then + if [ "$#" -lt 4 ]; then + echo "rd.znet for type qeth needs at least 4 list items: qeth,subchannel1,subchannel2,subchannel3" | znet_vinfo + fi + subchannels="$subchannel1:$subchannel2:$subchannel3" + shift 4 + # shellcheck disable=SC2086 + chzdev --enable --persistent $znet_base_args \ + "$type" "$subchannels" "$@" 2>&1 | znet_vinfo + else + subchannels="$subchannel1:$subchannel2" + shift 3 + # shellcheck disable=SC2086 + chzdev --enable --persistent $znet_base_args \ + "$type" "$subchannels" "$@" 2>&1 | znet_vinfo + fi + ) done for ifname in $(getargs rd.znet_ifname); do @@ -21,5 +64,3 @@ for ifname in $(getargs rd.znet_ifname); do } > /etc/udev/rules.d/81-ccw-ifname.rules fi done - -znet_cio_free From 2ba3d441a1602cac8954225819efad3c64626371 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 26 May 2023 19:25:41 +0200 Subject: [PATCH 12/19] docs(dracut.cmdline): generalize description of rd.znet As of the preceding commit ("feat(znet): use zdev for consolidated device configuration"), rd.znet is no longer specific to RHEL/Fedora. Signed-off-by: Steffen Maier --- man/dracut.cmdline.7.asc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc index 21c8cda960..c64b87a08a 100644 --- a/man/dracut.cmdline.7.asc +++ b/man/dracut.cmdline.7.asc @@ -1017,9 +1017,12 @@ rd.zfcp=0.0.4000 ZNET ~~~~ **rd.znet=**____,____,____:: - The whole parameter is appended to /etc/ccw.conf, which is used on - RHEL/Fedora with ccw_init, which is called from udev for certain - devices on z-series. + Activates a channel-attached network interface on s390 architecture. + is one of: qeth, lcs, ctc. + is a comma-separated list of ccw device bus-IDs. + The list consists of 3 entries with nettype qeth, and 2 for other nettype. + is a comma-separated list of = pairs, + where refers to a device sysfs attribute to which gets written. rd.znet can be specified multiple times on the kernel command line. **rd.znet_ifname=**____:____:: From 4fed82cc0dbe4f66fd2da56b08d69e9496e8ca18 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 26 May 2023 19:51:09 +0200 Subject: [PATCH 13/19] feat(qeth_rules): remove qeth handling consolidated in 95znet Dracut module 95znet handles a superset of qeth_rules as of the preceding commit ("feat(znet): use zdev for consolidated device configuration"). The instmods list in installkernel() seemed to have been incomplete because qeth needs one or both of qeth_l2 and qeth_l3 but qeth intentionally does not depend on them so depmod cannot resolve that. In contrast to the old dracut module 95znet, 95qeth_rules also did not seem to have parsing for the upstream dracut cmdline options "rd.znet=" and "rd.znet_ifname=". Signed-off-by: Steffen Maier --- .github/labeler.yml | 4 -- modules.d/95qeth_rules/module-setup.sh | 58 -------------------------- 2 files changed, 62 deletions(-) delete mode 100755 modules.d/95qeth_rules/module-setup.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index 19b05e182f..dda81b275b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -422,10 +422,6 @@ nvmf: - changed-files: - any-glob-to-any-file: 'modules.d/95nvmf/*' -qeth_rules: - - changed-files: - - any-glob-to-any-file: 'modules.d/95qeth_rules/*' - resume: - changed-files: - any-glob-to-any-file: 'modules.d/95resume/*' diff --git a/modules.d/95qeth_rules/module-setup.sh b/modules.d/95qeth_rules/module-setup.sh deleted file mode 100755 index a84ac1514d..0000000000 --- a/modules.d/95qeth_rules/module-setup.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - local _online=0 - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - dracut_module_included network || return 1 - - [[ $hostonly ]] && { - for i in /sys/devices/qeth/*/online; do - [ ! -f "$i" ] && continue - read -r _online < "$i" - [ "$_online" -eq 1 ] && return 0 - done - } - return 255 -} - -# called by dracut -installkernel() { - instmods qeth -} - -# called by dracut -install() { - ccwid() { - qeth_path=$(readlink -e -q "$1"/device) - basename "$qeth_path" - } - - inst_rules_qeth() { - for rule in /etc/udev/rules.d/{4,5}1-qeth-${1}.rules; do - # prefer chzdev generated 41- rules - if [ -f "$rule" ]; then - inst_rules "$rule" - break - fi - done - } - - has_carrier() { - carrier=0 - # not readable in qeth interfaces - # that have just been assembled, ignore - # read error and assume no carrier - read -r carrier 2> /dev/null < "$1/carrier" - [ "$carrier" -eq 1 ] && return 0 - return 1 - } - - for dev in /sys/class/net/*; do - has_carrier "$dev" || continue - id=$(ccwid "$dev") - [ -n "$id" ] && inst_rules_qeth "$id" - done - -} From b0197bc27db73d4781f4fd8f48adb0a248232dcb Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 26 May 2023 19:47:35 +0200 Subject: [PATCH 14/19] fix(znet): append to udev rules so each rd.znet_ifname is effective Otherwise the last rd.znet_ifname statement overwrites the persistent network interface settings of previous such statements. Signed-off-by: Steffen Maier --- modules.d/95znet/parse-ccw.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules.d/95znet/parse-ccw.sh b/modules.d/95znet/parse-ccw.sh index aacc988e4e..ccf05bc66e 100755 --- a/modules.d/95znet/parse-ccw.sh +++ b/modules.d/95znet/parse-ccw.sh @@ -53,14 +53,16 @@ for ifname in $(getargs rd.znet_ifname); do warn "Invalid arguments for rd.znet_ifname=" else { - ifname_subchannels=${ifname_subchannels//,/|} + ifname_subchannels="${ifname_subchannels//,/|}" + # sanitize for use in udev label: replace non-word characters by _ + ifname_if_label="${ifname_if//[^[:word:]]/_}" - echo 'ACTION!="add|change", GOTO="ccw_ifname_end"' - echo 'ATTR{type}!="1", GOTO="ccw_ifname_end"' - echo 'SUBSYSTEM!="net", GOTO="ccw_ifname_end"' + echo "ACTION!=\"add|change\", GOTO=\"ccw_ifname_${ifname_if_label}_end\"" + echo "ATTR{type}!=\"1\", GOTO=\"ccw_ifname_${ifname_if_label}_end\"" + echo "SUBSYSTEM!=\"net\", GOTO=\"ccw_ifname_${ifname_if_label}_end\"" echo "SUBSYSTEMS==\"ccwgroup\", KERNELS==\"$ifname_subchannels\", DRIVERS==\"?*\" NAME=\"$ifname_if\"" - echo 'LABEL="ccw_ifname_end"' + echo "LABEL=\"ccw_ifname_${ifname_if_label}_end\"" - } > /etc/udev/rules.d/81-ccw-ifname.rules + } >> /etc/udev/rules.d/81-ccw-ifname.rules fi done From 71688c12d0894302f7418bd39b24d80dea4edce6 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 26 Jul 2023 12:42:03 +0200 Subject: [PATCH 15/19] refactor(ifcfg): delete code duplication using iface_get_subchannels() Signed-off-by: Steffen Maier --- modules.d/45ifcfg/write-ifcfg.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh index 5550cce305..4ca96e9872 100755 --- a/modules.d/45ifcfg/write-ifcfg.sh +++ b/modules.d/45ifcfg/write-ifcfg.sh @@ -31,19 +31,13 @@ print_s390() { local NETTYPE local CONFIG_LINE local i - local channel local OLD_IFS _netif="$1" # if we find ccw channel, then use those, instead of # of the MAC - SUBCHANNELS=$({ - for i in /sys/class/net/"$_netif"/device/cdev[0-9]*; do - [ -e "$i" ] || continue - channel=$(readlink -f "$i") - printf '%s' "${channel##*/}," - done - }) + # [iface_get_subchannels() from /lib/net-lib.sh sourced at top of this file] + SUBCHANNELS=$(iface_get_subchannels "$_netif") [ -n "$SUBCHANNELS" ] || return 1 SUBCHANNELS=${SUBCHANNELS%,} From b2f337332794879d4caf23ae558a5d9f2aa5ffe3 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 26 Jul 2023 12:59:19 +0200 Subject: [PATCH 16/19] feat(ifcfg): minimize s390-specific network configuration aspects Since consolidated s390 network device configuration with zdev is used, it takes care of all s390-specific settings. None of the s390-specific ifcfg variables should be used anymore. NETTYPE and OPTIONS can be removed entirely. SUBCHANNELS is kept because there are some dependency chains (probably around the interface identifiying key, which is not HWADDR): modules.d/35network-legacy/module-setup.sh parses (sources) each of /etc/sysconfig/network-scripts/ifcfg-* and if that contains SUBCHANNELS, creates a symlink from the ifcfg file to /etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf modules.d/35network-legacy/ifup.sh installed as /sbin/ifup checks during team setup if a slave interface is an s390 channel-attached network interface and then parses (sources) /etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf from above, if that file exists Signed-off-by: Steffen Maier --- modules.d/45ifcfg/write-ifcfg.sh | 41 -------------------------------- 1 file changed, 41 deletions(-) diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh index 4ca96e9872..a7804b5053 100755 --- a/modules.d/45ifcfg/write-ifcfg.sh +++ b/modules.d/45ifcfg/write-ifcfg.sh @@ -10,28 +10,10 @@ mkdir -m 0755 -p /tmp/ifcfg/ # shellcheck disable=SC2174 mkdir -m 0755 -p /tmp/ifcfg-leases/ -get_config_line_by_subchannel() { - local CHANNELS - local line - - CHANNELS="$1" - while read -r line || [ -n "$line" ]; do - if strstr "$line" "$CHANNELS"; then - echo "$line" - return 0 - fi - done < /etc/ccw.conf - return 1 -} - print_s390() { local _netif local SUBCHANNELS - local OPTIONS - local NETTYPE - local CONFIG_LINE local i - local OLD_IFS _netif="$1" # if we find ccw channel, then use those, instead of @@ -43,29 +25,6 @@ print_s390() { SUBCHANNELS=${SUBCHANNELS%,} echo "SUBCHANNELS=\"${SUBCHANNELS}\"" - CONFIG_LINE=$(get_config_line_by_subchannel "$SUBCHANNELS") - # shellcheck disable=SC2181 - [ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0 - - OLD_IFS=$IFS - IFS="," - # shellcheck disable=SC2086 - set -- $CONFIG_LINE - IFS=$OLD_IFS - NETTYPE=$1 - shift - SUBCHANNELS="$1" - OPTIONS="" - shift - while [ $# -gt 0 ]; do - case $1 in - *=*) OPTIONS="$OPTIONS $1" ;; - esac - shift - done - OPTIONS=${OPTIONS## } - echo "NETTYPE=\"${NETTYPE}\"" - echo "OPTIONS=\"${OPTIONS}\"" return 0 } From 0d375516df096fc1c892181a596b94cf66a33a64 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 23 Mar 2023 19:33:52 +0100 Subject: [PATCH 17/19] feat(zfcp): finally remove zfcp handling consolidated in s390-tools This final cleanup is based on the assumption that users have migrated their old deprecated persistent config with the help of s390utils zfcpconfmigrate.sh, potentially invoked by a distribution upgrade. Signed-off-by: Steffen Maier --- .github/labeler.yml | 4 ---- man/dracut.cmdline.7.asc | 6 +++++- modules.d/95zfcp/module-setup.sh | 34 -------------------------------- modules.d/95zfcp/parse-zfcp.sh | 5 ----- 4 files changed, 5 insertions(+), 44 deletions(-) delete mode 100755 modules.d/95zfcp/module-setup.sh delete mode 100755 modules.d/95zfcp/parse-zfcp.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index dda81b275b..eb9af015a6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -450,10 +450,6 @@ virtiofs: - changed-files: - any-glob-to-any-file: 'modules.d/95virtiofs/*' -zfcp: - - changed-files: - - any-glob-to-any-file: 'modules.d/95zfcp/*' - znet: - changed-files: - any-glob-to-any-file: 'modules.d/95znet/*' diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc index c64b87a08a..6d5f137647 100644 --- a/man/dracut.cmdline.7.asc +++ b/man/dracut.cmdline.7.asc @@ -1012,7 +1012,11 @@ rd.zfcp=0.0.4000 -- **rd.zfcp.conf=0**:: - ignore zfcp.conf included in the initramfs + ignore zfcp.conf included in the initramfs. ++ +NOTE: + This parameter no longer has any effect and is ignored. + The file /etc/zfcp.conf no longer gets included in the initramfs. ZNET ~~~~ diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh deleted file mode 100755 index b547f9bc14..0000000000 --- a/modules.d/95zfcp/module-setup.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# called by dracut -check() { - arch=${DRACUT_ARCH:-$(uname -m)} - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - - require_binaries zfcp_cio_free sed || return 1 - - return 0 -} - -# called by dracut -depends() { - return 0 -} - -# called by dracut -installkernel() { - instmods zfcp -} - -# called by dracut -install() { - inst_hook cmdline 30 "$moddir/parse-zfcp.sh" - inst_multiple zfcp_cio_free sed - - inst_script /sbin/zfcpconf.sh - inst_rules 56-zfcp.rules - - if [[ $hostonly ]]; then - inst_simple -H /etc/zfcp.conf - fi -} diff --git a/modules.d/95zfcp/parse-zfcp.sh b/modules.d/95zfcp/parse-zfcp.sh deleted file mode 100755 index 41216dd960..0000000000 --- a/modules.d/95zfcp/parse-zfcp.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -getargbool 1 rd.zfcp.conf -d -n rd_NO_ZFCPCONF || rm /etc/zfcp.conf - -zfcp_cio_free From 7b938146efcf96fc942d4d706a56201a40028684 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 12 May 2023 23:52:56 +0200 Subject: [PATCH 18/19] feat(dasd): finally remove dasd handling consolidated in s390-tools This final cleanup is based on the assumption that users have migrated their old deprecated persistent config with the help of s390utils dasdconfmigrate.sh, potentially invoked by a distribution upgrade. Signed-off-by: Steffen Maier --- .github/labeler.yml | 4 ---- modules.d/95dasd/module-setup.sh | 25 ------------------------- 2 files changed, 29 deletions(-) delete mode 100755 modules.d/95dasd/module-setup.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index eb9af015a6..f475e53e0e 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -374,10 +374,6 @@ cifs: - changed-files: - any-glob-to-any-file: 'modules.d/95cifs/*' -dasd: - - changed-files: - - any-glob-to-any-file: 'modules.d/95dasd/*' - dasd_mod: - changed-files: - any-glob-to-any-file: 'modules.d/95dasd_mod/*' diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh deleted file mode 100755 index 825f95d810..0000000000 --- a/modules.d/95dasd/module-setup.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - require_binaries dasdconf.sh || return 1 - return 0 -} - -# called by dracut -depends() { - return 0 -} - -# called by dracut -install() { - inst_multiple dasdconf.sh - conf=/etc/dasd.conf - if [[ $hostonly && -f $conf ]]; then - inst -H $conf - fi - inst_rules 56-dasd.rules - inst_rules 59-dasd.rules -} From 22e0a2bd3c0e5b00c3f35b8fe6513224603abb60 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 22 Feb 2024 18:29:30 +0100 Subject: [PATCH 19/19] feat(dasd_mod): finally remove dasd handling consolidated in s390-tools This final cleanup is based on the assumption that users have migrated their old deprecated persistent config with the help of s390utils dasdconfmigrate.sh, potentially invoked by a distribution upgrade. Signed-off-by: Steffen Maier --- .github/labeler.yml | 4 ---- modules.d/95dasd_mod/module-setup.sh | 25 ------------------------- modules.d/95dasd_mod/parse-dasd-mod.sh | 4 ---- 3 files changed, 33 deletions(-) delete mode 100755 modules.d/95dasd_mod/module-setup.sh delete mode 100755 modules.d/95dasd_mod/parse-dasd-mod.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index f475e53e0e..8136d5c943 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -374,10 +374,6 @@ cifs: - changed-files: - any-glob-to-any-file: 'modules.d/95cifs/*' -dasd_mod: - - changed-files: - - any-glob-to-any-file: 'modules.d/95dasd_mod/*' - dcssblk: - changed-files: - any-glob-to-any-file: 'modules.d/95dcssblk/*' diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh deleted file mode 100755 index 155eaacc71..0000000000 --- a/modules.d/95dasd_mod/module-setup.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - - return 0 -} - -# called by dracut -depends() { - return 0 -} - -# called by dracut -installkernel() { - instmods dasd_mod dasd_eckd_mod dasd_fba_mod dasd_diag_mod -} - -# called by dracut -install() { - inst_hook cmdline 31 "$moddir/parse-dasd-mod.sh" - inst_multiple -o dasd_cio_free -} diff --git a/modules.d/95dasd_mod/parse-dasd-mod.sh b/modules.d/95dasd_mod/parse-dasd-mod.sh deleted file mode 100755 index b635ecf9c2..0000000000 --- a/modules.d/95dasd_mod/parse-dasd-mod.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -if [ -x /sbin/dasd_cio_free ]; then - dasd_cio_free -fi