File kdump-device-timeout.patch of Package kdump.624

From: Petr Tesarik <ptesarik@suse.cz>
Subject: Set up device timeout for kdump mounts
References: bsc#909515
Patch-mainline: not yet

When using systemd to mount local filesystems in the kdump initrd, default
job timeout is set to 90s. Systems with many LUNs may take much longer just
to enumerate the SCSI bus. Solve that by adopting dracut's rootfs defaults
and overrides:

* By default there is no timeout for the kdump target devices.
* A timeout can be specified using the rd.timeout parameter on the kernel
  command line.

See also dracut.cmdline(7).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 init/CMakeLists.txt              |    1 +
 init/device-timeout-generator.sh |   23 +++++++++++++++++++++++
 init/module-setup.sh             |    5 ++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

--- /dev/null
+++ b/init/device-timeout-generator.sh
@@ -0,0 +1,23 @@
+#! /bin/sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+timeout=$(getarg rd.timeout)
+timeout=${timeout:-0}
+
+unitdir="$1"
+
+while read device mountpoint filesystem opts dummy
+do
+    test "${mountpoint#/kdump/}" = "$mountpoint" && continue
+
+    name=$(dev_unit_name "$device")
+    devdir="${unitdir}/${name}.device.d"
+    mkdir -p "$devdir"
+    {
+        echo "[Unit]"
+        echo "JobTimeoutSec=$timeout"
+    } > "${devdir}/timeout.conf"
+done < <(sed -e 's/[ \t][ \t]*/\t/g;s/^\t//;/^$/d;/^#/d' /etc/fstab)
+
+exit 0
--- a/init/CMakeLists.txt
+++ b/init/CMakeLists.txt
@@ -70,6 +70,7 @@ INSTALL(
 INSTALL(
     FILES
         ${CMAKE_CURRENT_SOURCE_DIR}/kdump-root.sh
+        ${CMAKE_CURRENT_SOURCE_DIR}/device-timeout-generator.sh
         ${CMAKE_CURRENT_SOURCE_DIR}/module-setup.sh
         ${CMAKE_CURRENT_SOURCE_DIR}/mount-kdump.sh
     DESTINATION
--- a/init/module-setup.sh
+++ b/init/module-setup.sh
@@ -142,8 +142,11 @@ install() {
 
     inst_hook cmdline 50 "$moddir/kdump-root.sh"
     if dracut_module_included "systemd" ; then
-	[ "$KDUMP_FADUMP" != yes ] && \
+	if [ "$KDUMP_FADUMP" != yes ] ; then
 	    rm -f "${initdir}/$systemdutildir"/system-generators/dracut-rootfs-generator
+	    inst_script "$moddir/device-timeout-generator.sh" \
+		"$systemdutildir"/system-generators/kdump-device-timeout-generator
+	fi
 
 	inst_simple /lib/kdump/save_dump.sh
 	inst_simple "$moddir/kdump-save.service" \