Harald Hoyer 460d2c
From dc9596155def879c99caa03acc5bd6d7090488ed Mon Sep 17 00:00:00 2001
Harald Hoyer 460d2c
From: Kairui Song <kasong@redhat.com>
Harald Hoyer 460d2c
Date: Fri, 2 Aug 2019 17:11:19 +0800
Harald Hoyer 460d2c
Subject: [PATCH] dracut-initqueue: Print more useful info in case of timeout
Harald Hoyer 460d2c
Harald Hoyer 460d2c
Currently when initqueue timeout, it span the console with
Harald Hoyer 460d2c
"dracut-initqueue timeout - starting timeout scripts", which isn't very
Harald Hoyer 460d2c
helpful as we still don't know what actually happened. Try to improve
Harald Hoyer 460d2c
this by print what is actually being waited.
Harald Hoyer 460d2c
Harald Hoyer 460d2c
Besides, only print "starting timeout scripts" when there are
Harald Hoyer 460d2c
actual timeout scripts to use.
Harald Hoyer 460d2c
Harald Hoyer 460d2c
Signed-off-by: Kairui Song <kasong@redhat.com>
Harald Hoyer 460d2c
---
Harald Hoyer 460d2c
 modules.d/98dracut-systemd/dracut-initqueue.sh | 20 +++++++++++++-------
Harald Hoyer 460d2c
 1 file changed, 13 insertions(+), 7 deletions(-)
Harald Hoyer 460d2c
Harald Hoyer 460d2c
diff --git a/modules.d/98dracut-systemd/dracut-initqueue.sh b/modules.d/98dracut-systemd/dracut-initqueue.sh
Harald Hoyer 460d2c
index 3ddc2362..89225995 100755
Harald Hoyer 460d2c
--- a/modules.d/98dracut-systemd/dracut-initqueue.sh
Harald Hoyer 460d2c
+++ b/modules.d/98dracut-systemd/dracut-initqueue.sh
Harald Hoyer 460d2c
@@ -55,14 +55,20 @@ while :; do
Harald Hoyer 460d2c
     done
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
     if [ $main_loop -gt $((2*$RDRETRY/3)) ]; then
Harald Hoyer 460d2c
-        warn "dracut-initqueue timeout - starting timeout scripts"
Harald Hoyer 460d2c
-        for job in $hookdir/initqueue/timeout/*.sh; do
Harald Hoyer 460d2c
-            [ -e "$job" ] || break
Harald Hoyer 460d2c
-            job=$job . $job
Harald Hoyer 460d2c
-            udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0
Harald Hoyer 460d2c
-            [ -f $hookdir/initqueue/work ] && main_loop=0
Harald Hoyer 460d2c
-            [ $main_loop -eq 0 ] && break
Harald Hoyer 460d2c
+        warn "dracut-initqueue: timeout, still waiting for following initqueue hooks:"
Harald Hoyer 460d2c
+        for _f in $hookdir/initqueue/finished/*.sh; do
Harald Hoyer 460d2c
+            warn "$_f: \"$(cat "$_f")\""
Harald Hoyer 460d2c
         done
Harald Hoyer 460d2c
+        if [ "$(ls -A $hookdir/initqueue/finished)" ]; then
Harald Hoyer 460d2c
+            warn "dracut-initqueue: starting timeout scripts"
Harald Hoyer 460d2c
+            for job in $hookdir/initqueue/timeout/*.sh; do
Harald Hoyer 460d2c
+                [ -e "$job" ] || break
Harald Hoyer 460d2c
+                job=$job . $job
Harald Hoyer 460d2c
+                udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0
Harald Hoyer 460d2c
+                [ -f $hookdir/initqueue/work ] && main_loop=0
Harald Hoyer 460d2c
+                [ $main_loop -eq 0 ] && break
Harald Hoyer 460d2c
+            done
Harald Hoyer 460d2c
+        fi
Harald Hoyer 460d2c
     fi
Harald Hoyer 460d2c
 
Harald Hoyer 460d2c
     main_loop=$(($main_loop+1))
Harald Hoyer 460d2c