Blame SOURCES/0272-base-Don-t-wait-for-swap-devices-in-host-only-mode.patch

712866
From 589b4e61e2db2a5835b5aa425268f6f0f67c14e4 Mon Sep 17 00:00:00 2001
712866
From: Colin Guthrie <colin@mageia.org>
712866
Date: Fri, 15 May 2015 14:53:40 +0100
712866
Subject: [PATCH] base: Don't wait for swap devices in host-only mode.
712866
712866
The only reason we add swap devices to host-only mode (added in
712866
dd5875499ece9dbc90e10eafd0073ee15d0c86a4) is to allow us to process
712866
resume= arguments passed on the kernel command line when the swap
712866
partition lives on something slightly more complex than a normal
712866
partion (e.g. in an LVM or RAID setup).
712866
712866
By adding the device to host_devs, the necessary LVM and RAID hooks
712866
are added and thus the underlying storage will be initialised OK, and
712866
the 95resume module handles the waiting for the device (via udev rules
712866
creating the /dev/resume symlink).
712866
712866
So ultimately, we do not need to hard-code the waiting for the swap
712866
devices into the initramfs at build time as the waiting part can be
712866
dynamic.
712866
712866
This makes things more resiliant to swap partitions disappearing and
712866
being reformatted etc.
712866
712866
Inspired by a patch by Martin Whitaker on Mageia bug:
712866
https://bugs.mageia.org/show_bug.cgi?id=12305
712866
712866
(cherry picked from commit 3e3ed34f036a833ccc2150c6224d0a954e841e39)
712866
---
712866
 dracut.sh                        | 6 ++++--
712866
 modules.d/99base/module-setup.sh | 8 ++++++++
712866
 2 files changed, 12 insertions(+), 2 deletions(-)
712866
712866
diff --git a/dracut.sh b/dracut.sh
5c6c2a
index a214f810..90ac1fe9 100755
712866
--- a/dracut.sh
712866
+++ b/dracut.sh
712866
@@ -1056,7 +1056,9 @@ if [[ $hostonly ]]; then
712866
                     done < /etc/crypttab
712866
                 fi
712866
 
712866
-                push host_devs "$(readlink -f "$dev")"
712866
+                _dev="$(readlink -f "$dev")"
712866
+                push host_devs "$_dev"
712866
+                push swap_devs "$_dev"
712866
                 break
712866
             done < /etc/fstab
712866
         done < /proc/swaps
712866
@@ -1181,7 +1183,7 @@ export initdir dracutbasedir \
712866
     omit_drivers mdadmconf lvmconf root_dev \
712866
     use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
712866
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
712866
-    debug host_fs_types host_devs sshkey add_fstab \
712866
+    debug host_fs_types host_devs swap_devs sshkey add_fstab \
712866
     DRACUT_VERSION udevdir prefix filesystems drivers \
712866
     systemdutildir systemdsystemunitdir systemdsystemconfdir \
712866
     host_modalias host_modules hostonly_cmdline loginstall \
712866
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
5c6c2a
index fddf4b06..d5e78613 100755
712866
--- a/modules.d/99base/module-setup.sh
712866
+++ b/modules.d/99base/module-setup.sh
712866
@@ -104,6 +104,14 @@ install() {
712866
 
712866
                 for _dev in ${host_devs[@]}; do
712866
                     [[ "$_dev" == "$root_dev" ]] && continue
712866
+
712866
+                    # We only actually wait for real devs - swap is only needed
712866
+                    # for resume and udev rules generated when parsing resume=
712866
+                    # argument take care of the waiting for us
712866
+                    for _dev2 in ${swap_devs[@]}; do
712866
+                      [[ "$_dev" == "$_dev2" ]] && continue 2
712866
+                    done
712866
+
712866
                     _pdev=$(get_persistent_dev $_dev)
712866
 
712866
                     case "$_pdev" in