From 480aa9695f8c2e2b30c8f41ae8483140020d23db Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Tue, 4 Aug 2020 10:20:51 +0200 Subject: [PATCH] 95resume: Do not resume on iSCSI, FCoE or NBD The iSCSI configuration is started after dracut checks for resume, so we run into a timeout here. Additionally it's questionable if resume on iSCSI makes sense (or is even supported on the platform). Same holds true for Network Block Devices and FcOE, cover those as well References: bsc#999663 Original-patch-by: Hannes Reinecke Signed-off-by: Daniel Molkentin --- dracut-functions.sh | 44 ++++++++++++++++++++++++++++++++++++++ modules.d/95iscsi/module-setup.sh | 14 ++---------- modules.d/95nbd/module-setup.sh | 4 +--- modules.d/95resume/module-setup.sh | 11 +++++++++- 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/dracut-functions.sh b/dracut-functions.sh index 07ae88c0..e0ca7574 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -842,3 +842,47 @@ ip_params_for_remote_addr() { fi } + +# block_is_nbd +# Check whether $1 is an nbd device +block_is_nbd() { + [[ -b /dev/block/$1 && $1 == 43:* ]] +} + +# block_is_iscsi +# Check whether $1 is an nbd device +block_is_iscsi() { + local _dir + local _dev=$1 + [[ -L "/sys/dev/block/$_dev" ]] || return + _dir="$(readlink -f "/sys/dev/block/$_dev")" || return + until [[ -d "$_dir/sys" || -d "$_dir/iscsi_session" ]]; do + _dir="$_dir/.." + done + [[ -d "$_dir/iscsi_session" ]] +} + +# block_is_fcoe +# Check whether $1 is an FCoE device +# Will not work for HBAs that hide the ethernet aspect +# completely and present a pure FC device +block_is_fcoe() { + local _dir + local _dev=$1 + [[ -L "/sys/dev/block/$_dev" ]] || return + _dir="$(readlink -f "/sys/dev/block/$_dev")" + until [[ -d "$_dir/sys" ]]; do + _dir="$_dir/.." + if [[ -d "$_dir/subsystem" ]]; then + subsystem=$(basename $(readlink $_dir/subsystem)) + [[ $subsystem == "fcoe" ]] && return 0 + fi + done + return 1 +} + +# block_is_netdevice +# Check whether $1 is a net device +block_is_netdevice() { + block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1" +} diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh index dfacd797..20922442 100755 --- a/modules.d/95iscsi/module-setup.sh +++ b/modules.d/95iscsi/module-setup.sh @@ -9,20 +9,9 @@ check() { # If hostonly was requested, fail the check if we are not actually # booting from root. - is_iscsi() { - local _dev=$1 - - [[ -L "/sys/dev/block/$_dev" ]] || return - cd "$(readlink -f "/sys/dev/block/$_dev")" - until [[ -d sys || -d iscsi_session ]]; do - cd .. - done - [[ -d iscsi_session ]] - } - [[ $hostonly ]] || [[ $mount_needs ]] && { pushd . >/dev/null - for_each_host_dev_and_slaves is_iscsi + for_each_host_dev_and_slaves block_is_iscsi local _is_iscsi=$? popd >/dev/null [[ $_is_iscsi == 0 ]] || return 255 @@ -223,6 +212,7 @@ install() { inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh" inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh" inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot" + if ! dracut_module_included "systemd"; then inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh" else diff --git a/modules.d/95nbd/module-setup.sh b/modules.d/95nbd/module-setup.sh index 22f6a3bf..9254b49a 100755 --- a/modules.d/95nbd/module-setup.sh +++ b/modules.d/95nbd/module-setup.sh @@ -7,11 +7,9 @@ check() { # if an nbd device is not somewhere in the chain of devices root is # mounted on, fail the hostonly check. [[ $hostonly ]] || [[ $mount_needs ]] && { - is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;} - _rootdev=$(find_root_block_device) [[ -b /dev/block/$_rootdev ]] || return 1 - check_block_and_slaves is_nbd "$_rootdev" || return 255 + check_block_and_slaves block_is_nbd "$_rootdev" || return 255 } require_binaries nbd-client || return 1 diff --git a/modules.d/95resume/module-setup.sh b/modules.d/95resume/module-setup.sh index cb06b567..96c2573e 100755 --- a/modules.d/95resume/module-setup.sh +++ b/modules.d/95resume/module-setup.sh @@ -2,9 +2,18 @@ # called by dracut check() { + swap_on_netdevice() { + local _dev + for _dev in "${swap_devs[@]}"; do + block_is_netdevice $_dev && return 0 + done + return 1 + } + # Only support resume if hibernation is currently on + # and no swap is mounted on a net device [[ $hostonly ]] || [[ $mount_needs ]] && { - [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255 + swap_on_netdevice || [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255 } return 0