Blame 0005-base-dracut-lib.sh-wait_for_dev-cancel_wait_for_dev-.patch

Harald Hoyer 38a2dd
From 6db8c5a5fe5b77de757e7b669c8277cd2dafaf8e Mon Sep 17 00:00:00 2001
Harald Hoyer 38a2dd
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 38a2dd
Date: Thu, 4 Apr 2013 12:56:42 +0200
Harald Hoyer 38a2dd
Subject: [PATCH] base/dracut-lib.sh:wait_for_dev()/cancel_wait_for_dev() set
Harald Hoyer 38a2dd
 systemd timeouts
Harald Hoyer 38a2dd
Harald Hoyer 38a2dd
Set systemd unit timeouts for the devices we wait for. The systemd
Harald Hoyer 38a2dd
default is 90 seconds, which is way too low for complicated setups.
Harald Hoyer 38a2dd
---
Harald Hoyer 38a2dd
 modules.d/99base/dracut-lib.sh     | 15 ++++++++++++++-
Harald Hoyer 38a2dd
 modules.d/99base/module-setup.sh   | 14 +++++++-------
Harald Hoyer 38a2dd
 modules.d/99base/wait-host-devs.sh | 20 --------------------
Harald Hoyer 38a2dd
 3 files changed, 21 insertions(+), 28 deletions(-)
Harald Hoyer 38a2dd
 delete mode 100644 modules.d/99base/wait-host-devs.sh
Harald Hoyer 38a2dd
Harald Hoyer 38a2dd
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 38a2dd
index 79fc953..f2b16d3 100755
Harald Hoyer 38a2dd
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 38a2dd
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 38a2dd
@@ -849,6 +849,13 @@ wait_for_dev()
Harald Hoyer 38a2dd
             [ -d ${PREFIX}/etc/systemd/system/initrd.target.requires ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.requires
Harald Hoyer 38a2dd
             ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device
Harald Hoyer 38a2dd
         fi
Harald Hoyer 38a2dd
+
Harald Hoyer 38a2dd
+        mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d
Harald Hoyer 38a2dd
+        {
Harald Hoyer 38a2dd
+            echo "[Unit]"
Harald Hoyer 38a2dd
+            echo "JobTimeoutSec=3600"
Harald Hoyer 38a2dd
+        } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
Harald Hoyer 38a2dd
+        [ -z "$PREFIX" ] && /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload
Harald Hoyer 38a2dd
     fi
Harald Hoyer 38a2dd
 }
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
@@ -858,6 +865,12 @@ cancel_wait_for_dev()
Harald Hoyer 38a2dd
     _name="$(str_replace "$1" '/' '\\x2f')"
Harald Hoyer 38a2dd
     rm -f "$hookdir/initqueue/finished/devexists-${_name}.sh"
Harald Hoyer 38a2dd
     rm -f "$hookdir/emergency/80-${_name}.sh"
Harald Hoyer 38a2dd
+    if [ -n "$DRACUT_SYSTEMD" ]; then
Harald Hoyer 38a2dd
+        _name=$(dev_unit_name "$1")
Harald Hoyer 38a2dd
+        rm -f ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device
Harald Hoyer 38a2dd
+        rm -f ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
Harald Hoyer 38a2dd
+        /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload
Harald Hoyer 38a2dd
+    fi
Harald Hoyer 38a2dd
 }
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
 killproc() {
Harald Hoyer 38a2dd
@@ -1023,7 +1036,7 @@ listlist() {
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
 # returns OK if both lists contain the same values.  An order and a duplication
Harald Hoyer 38a2dd
 # doesn't matter.
Harald Hoyer 38a2dd
-# 
Harald Hoyer 38a2dd
+#
Harald Hoyer 38a2dd
 # $1 = separator
Harald Hoyer 38a2dd
 # $2 = list1
Harald Hoyer 38a2dd
 # $3 = list2
Harald Hoyer 38a2dd
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
Harald Hoyer 38a2dd
index 7f2940b..4955b7b 100755
Harald Hoyer 38a2dd
--- a/modules.d/99base/module-setup.sh
Harald Hoyer 38a2dd
+++ b/modules.d/99base/module-setup.sh
Harald Hoyer 38a2dd
@@ -89,18 +89,18 @@ install() {
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
     ## save host_devs which we need bring up
Harald Hoyer 38a2dd
     (
Harald Hoyer 38a2dd
+        if dracut_module_included "systemd"; then
Harald Hoyer 38a2dd
+            DRACUT_SYSTEMD=1
Harald Hoyer 38a2dd
+        fi
Harald Hoyer 38a2dd
+        PREFIX="$initdir"
Harald Hoyer 38a2dd
+
Harald Hoyer 38a2dd
         . "$moddir/dracut-lib.sh"
Harald Hoyer 38a2dd
+
Harald Hoyer 38a2dd
         for _dev in ${host_devs[@]}; do
Harald Hoyer 38a2dd
             _pdev=$(get_persistent_dev $_dev)
Harald Hoyer 38a2dd
 
Harald Hoyer 38a2dd
             case "$_pdev" in
Harald Hoyer 38a2dd
-                /dev/?*)
Harald Hoyer 38a2dd
-                    if ! dracut_module_included "systemd"; then
Harald Hoyer 38a2dd
-                        PREFIX="$initdir" wait_for_dev $_pdev
Harald Hoyer 38a2dd
-                    else
Harald Hoyer 38a2dd
-                        DRACUT_SYSTEMD=1 PREFIX="$initdir" wait_for_dev $_pdev
Harald Hoyer 38a2dd
-                    fi
Harald Hoyer 38a2dd
-                    ;;
Harald Hoyer 38a2dd
+                /dev/?*) wait_for_dev $_pdev;;
Harald Hoyer 38a2dd
                 *) ;;
Harald Hoyer 38a2dd
             esac
Harald Hoyer 38a2dd
         done
Harald Hoyer 38a2dd
diff --git a/modules.d/99base/wait-host-devs.sh b/modules.d/99base/wait-host-devs.sh
Harald Hoyer 38a2dd
deleted file mode 100644
Harald Hoyer 38a2dd
index ce84922..0000000
Harald Hoyer 38a2dd
--- a/modules.d/99base/wait-host-devs.sh
Harald Hoyer 38a2dd
+++ /dev/null
Harald Hoyer 38a2dd
@@ -1,20 +0,0 @@
Harald Hoyer 38a2dd
-#!/bin/sh
Harald Hoyer 38a2dd
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer 38a2dd
-# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer 38a2dd
-
Harald Hoyer 38a2dd
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
Harald Hoyer 38a2dd
-
Harald Hoyer 38a2dd
-wait_host_devs() {
Harald Hoyer 38a2dd
-    local _dev
Harald Hoyer 38a2dd
-
Harald Hoyer 38a2dd
-    while read _dev; do
Harald Hoyer 38a2dd
-        case "$_dev" in
Harald Hoyer 38a2dd
-        /dev/?*)
Harald Hoyer 38a2dd
-            wait_for_dev $_dev
Harald Hoyer 38a2dd
-            ;;
Harald Hoyer 38a2dd
-        *) ;;
Harald Hoyer 38a2dd
-        esac
Harald Hoyer 38a2dd
-    done < $1
Harald Hoyer 38a2dd
-}
Harald Hoyer 38a2dd
-
Harald Hoyer 38a2dd
-[ -f /etc/host_devs ] && wait_host_devs /etc/host_devs