Blob Blame History Raw
From 28401778c4c95b3750e73675dd4a4867303402d5 Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Wed, 27 Sep 2017 13:27:42 +0200
Subject: [PATCH] systemd: fix setting of timeouts for device units

JobRunningTimeoutSec now affects how long can start jobs for device
units stay in the "running" state. Disabling default job timeout via
JobTimeoutSec=0 doesn't disable running state timeout. We need to set
running state timeout as well.

Note that doing this the other way around has effect on generic timeout,
i.e. disabling running state timeout disables generic timeout. But doing
it this way we would create implicit dependency on fairly new
systemd-234. However, by setting both options we don't create dependency
on specific systemd version.
---
 modules.d/90dmsquash-live/dmsquash-generator.sh | 1 +
 modules.d/90livenet/livenet-generator.sh        | 1 +
 modules.d/98dracut-systemd/rootfs-generator.sh  | 1 +
 modules.d/99base/dracut-lib.sh                  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/modules.d/90dmsquash-live/dmsquash-generator.sh b/modules.d/90dmsquash-live/dmsquash-generator.sh
index a5bfbdf2..d47cf14a 100755
--- a/modules.d/90dmsquash-live/dmsquash-generator.sh
+++ b/modules.d/90dmsquash-live/dmsquash-generator.sh
@@ -78,4 +78,5 @@ mkdir -p "$GENERATOR_DIR/$_dev.device.d"
 {
     echo "[Unit]"
     echo "JobTimeoutSec=3000"
+    echo "JobRunningTimeoutSec=3000"
 } > "$GENERATOR_DIR/$_dev.device.d/timeout.conf"
diff --git a/modules.d/90livenet/livenet-generator.sh b/modules.d/90livenet/livenet-generator.sh
index 969ef4f2..a349cd0b 100755
--- a/modules.d/90livenet/livenet-generator.sh
+++ b/modules.d/90livenet/livenet-generator.sh
@@ -57,4 +57,5 @@ mkdir -p "$GENERATOR_DIR/dev-mapper-live\x2drw.device.d"
 {
     echo "[Unit]"
     echo "JobTimeoutSec=3000"
+    echo "JobRunningTimeoutSec=3000"
 } > "$GENERATOR_DIR/dev-mapper-live\x2drw.device.d/timeout.conf"
diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh
index eada3d15..4ae693bb 100755
--- a/modules.d/98dracut-systemd/rootfs-generator.sh
+++ b/modules.d/98dracut-systemd/rootfs-generator.sh
@@ -32,6 +32,7 @@ generator_wait_for_dev()
         {
             echo "[Unit]"
             echo "JobTimeoutSec=$_timeout"
+            echo "JobRunningTimeoutSec=$_timeout"
         } > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf
     fi
 }
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 80385456..675abf22 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -938,6 +938,7 @@ set_systemd_timeout_for_dev()
             {
                 echo "[Unit]"
                 echo "JobTimeoutSec=$_timeout"
+                echo "JobRunningTimeoutSec=$_timeout"
             } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
             type mark_hostonly >/dev/null 2>&1 && mark_hostonly /etc/systemd/system/${_name}.device.d/timeout.conf
             _needreload=1