Skip to content

Commit

Permalink
95resume: Do not resume on iSCSI, FCoE or NBD
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Daniel Molkentin <[email protected]>
  • Loading branch information
danimo committed Aug 4, 2020
1 parent fe02bc7 commit 480aa96
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 16 deletions.
44 changes: 44 additions & 0 deletions dracut-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -842,3 +842,47 @@ ip_params_for_remote_addr() {
fi
}
# block_is_nbd <maj:min>
# Check whether $1 is an nbd device
block_is_nbd() {
[[ -b /dev/block/$1 && $1 == 43:* ]]
}
# block_is_iscsi <maj:min>
# 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 <maj:min>
# 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 <maj:min>
# Check whether $1 is a net device
block_is_netdevice() {
block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
}
14 changes: 2 additions & 12 deletions modules.d/95iscsi/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions modules.d/95nbd/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion modules.d/95resume/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 480aa96

Please sign in to comment.