]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
95resume: Do not resume on iSCSI, FCoE or NBD
authorDaniel Molkentin <dmolkentin@suse.com>
Tue, 4 Aug 2020 08:20:51 +0000 (10:20 +0200)
committerDaniel Molkentin <daniel@molkentin.de>
Tue, 4 Aug 2020 08:37:57 +0000 (10:37 +0200)
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 <hare@suse.com>
Signed-off-by: Daniel Molkentin <daniel.molkentin@suse.com>
dracut-functions.sh
modules.d/95iscsi/module-setup.sh
modules.d/95nbd/module-setup.sh
modules.d/95resume/module-setup.sh

index 07ae88c0f98cec8165ed283432c1d4e7184e8c2b..e0ca75742ea2b33720a0843af69445e23eb1d1b0 100755 (executable)
@@ -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"
+}
index dfacd7979a647bbf17ac6c9a5a91813f3c5461e6..20922442bd7f34e87c9a271ea7d4f729f05e90d3 100755 (executable)
@@ -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
index 22f6a3bfd298c8092ed2db62daabcec0eca8cca8..9254b49a57927b453b748d49db823d9a07f3119d 100755 (executable)
@@ -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
 
index cb06b567d3e35cd1fbcd6c8219b0ce640504c591..96c2573e11301879c20aa5314a2c363847e6ac56 100755 (executable)
@@ -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