Blame 0044-Implement-rd.timeout-to-modify-the-device-timeout.patch

Harald Hoyer b94732
From 56663e7e322cdba5d66cb45424489fd84791a544 Mon Sep 17 00:00:00 2001
Harald Hoyer b94732
From: Hannes Reinecke <hare@suse.de>
Harald Hoyer b94732
Date: Thu, 11 Dec 2014 15:46:05 +0100
Harald Hoyer b94732
Subject: [PATCH] Implement 'rd.timeout' to modify the device timeout
Harald Hoyer b94732
Harald Hoyer b94732
When generating units for devices the administrator might
Harald Hoyer b94732
want to use a different timeout than the default.
Harald Hoyer b94732
So implement a new parameter 'rd.timeout' for this.
Harald Hoyer b94732
Harald Hoyer b94732
References: bnc#878770
Harald Hoyer b94732
Harald Hoyer b94732
Signed-off-by: Hannes Reinecke <hare@suse.de>
Harald Hoyer b94732
Signed-off-by: Thomas Renninger <trenn@suse.de>
Harald Hoyer b94732
---
Harald Hoyer b94732
 dracut.cmdline.7.asc                    | 7 ++++++-
Harald Hoyer b94732
 modules.d/98systemd/rootfs-generator.sh | 7 +++++--
Harald Hoyer b94732
 modules.d/99base/dracut-lib.sh          | 6 +++++-
Harald Hoyer b94732
 3 files changed, 16 insertions(+), 4 deletions(-)
Harald Hoyer b94732
Harald Hoyer b94732
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer b94732
index 8e4835d..5ff84ef 100644
Harald Hoyer b94732
--- a/dracut.cmdline.7.asc
Harald Hoyer b94732
+++ b/dracut.cmdline.7.asc
Harald Hoyer b94732
@@ -142,11 +142,16 @@ Misc
Harald Hoyer b94732
     have been loaded. This parameter can be specified multiple times.
Harald Hoyer b94732
 
Harald Hoyer b94732
 **rd.retry=**__<seconds>__::
Harald Hoyer b94732
-    specify how long dracut should wait for devices to appear.
Harald Hoyer b94732
+    specify how long dracut should retry the initqueue to configure devices.
Harald Hoyer b94732
     The default is 30 seconds. After 2/3 of the time, degraded raids are force
Harald Hoyer b94732
     started. If you have hardware, which takes a very long time to announce its
Harald Hoyer b94732
     drives, you might want to extend this value.
Harald Hoyer b94732
 
Harald Hoyer b94732
+**rd.timeout=**__<seconds>__::
Harald Hoyer b94732
+    specify how long dracut should wait for devices to appear. The
Harald Hoyer b94732
+    default is '0', which means 'forever'. Note that this timeout
Harald Hoyer b94732
+    should be longer than rd.retry to allow for proper configuration.
Harald Hoyer b94732
+
Harald Hoyer b94732
 **rd.noverifyssl**::
Harald Hoyer b94732
     accept self-signed certificates for ssl downloads.
Harald Hoyer b94732
 
Harald Hoyer b94732
diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
Harald Hoyer b94732
index 9523729..5b06137 100755
Harald Hoyer b94732
--- a/modules.d/98systemd/rootfs-generator.sh
Harald Hoyer b94732
+++ b/modules.d/98systemd/rootfs-generator.sh
Harald Hoyer b94732
@@ -5,8 +5,11 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
Harald Hoyer b94732
 generator_wait_for_dev()
Harald Hoyer b94732
 {
Harald Hoyer b94732
     local _name
Harald Hoyer b94732
+    local _timeout
Harald Hoyer b94732
 
Harald Hoyer b94732
     _name="$(str_replace "$1" '/' '\x2f')"
Harald Hoyer b94732
+    _timeout=$(getarg rd.timeout)
Harald Hoyer b94732
+    _timeout=${_timeout:-0}
Harald Hoyer b94732
 
Harald Hoyer b94732
     [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
Harald Hoyer b94732
 
Harald Hoyer b94732
@@ -27,7 +30,7 @@ generator_wait_for_dev()
Harald Hoyer b94732
         mkdir -p /run/systemd/generator/${_name}.device.d
Harald Hoyer b94732
         {
Harald Hoyer b94732
             echo "[Unit]"
Harald Hoyer b94732
-            echo "JobTimeoutSec=0"
Harald Hoyer b94732
+            echo "JobTimeoutSec=$_timeout"
Harald Hoyer b94732
         } > /run/systemd/generator/${_name}.device.d/timeout.conf
Harald Hoyer b94732
     fi
Harald Hoyer b94732
 }
Harald Hoyer b94732
@@ -58,6 +61,6 @@ case "$root" in
Harald Hoyer b94732
         rootok=1 ;;
Harald Hoyer b94732
 esac
Harald Hoyer b94732
 
Harald Hoyer b94732
-[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
Harald Hoyer b94732
+[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}" "$RDRETRY"
Harald Hoyer b94732
 
Harald Hoyer b94732
 exit 0
Harald Hoyer b94732
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer b94732
index 5fc5615..f7cffc4 100755
Harald Hoyer b94732
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer b94732
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer b94732
@@ -890,12 +890,16 @@ wait_for_dev()
Harald Hoyer b94732
     local _name
Harald Hoyer b94732
     local _needreload
Harald Hoyer b94732
     local _noreload
Harald Hoyer b94732
+    local _timeout
Harald Hoyer b94732
 
Harald Hoyer b94732
     if [ "$1" = "-n" ]; then
Harald Hoyer b94732
         _noreload=1
Harald Hoyer b94732
         shift
Harald Hoyer b94732
     fi
Harald Hoyer b94732
 
Harald Hoyer b94732
+    _timeout=$(getarg rd.timeout)
Harald Hoyer b94732
+    _timeout=${_timeout:-0}
Harald Hoyer b94732
+
Harald Hoyer b94732
     _name="$(str_replace "$1" '/' '\x2f')"
Harald Hoyer b94732
 
Harald Hoyer b94732
     type mark_hostonly >/dev/null 2>&1 && mark_hostonly "$hookdir/initqueue/finished/devexists-${_name}.sh"
Harald Hoyer b94732
@@ -922,7 +926,7 @@ wait_for_dev()
Harald Hoyer b94732
             mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d
Harald Hoyer b94732
             {
Harald Hoyer b94732
                 echo "[Unit]"
Harald Hoyer b94732
-                echo "JobTimeoutSec=0"
Harald Hoyer b94732
+                echo "JobTimeoutSec=$_timeout"
Harald Hoyer b94732
             } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
Harald Hoyer b94732
             type mark_hostonly >/dev/null 2>&1 && mark_hostonly /etc/systemd/system/${_name}.device.d/timeout.conf
Harald Hoyer b94732
             _needreload=1