]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
99base: add timeout queue
authorHarald Hoyer <harald@redhat.com>
Fri, 5 Aug 2011 09:53:41 +0000 (11:53 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 11 Aug 2011 12:27:25 +0000 (14:27 +0200)
timeout queue is executed after half of the maximum retry count and if
jobs are found there, the counter is reset to zero.

dracut.xml
modules.d/99base/init
modules.d/99base/initqueue
modules.d/99base/module-setup.sh

index ac78e83bbc4a5bbb865bf1c35fa0bea7b616697b..13e092a6c429e7dd3a96b166644f01067327ce3d 100644 (file)
@@ -572,7 +572,7 @@ Common used functions are in <filename>dracut-lib.sh</filename>, which can be so
       </section>
       <section>
         <title>Main Loop</title>
-        <para>Now the main loop of <command>99base/init</command> begins. Here we loop until <command>udev</command> has settled and all scripts in <filename>initqueue-finished</filename> returned true. In this loop there are three hooks, where scripts can be inserted by calling <command>/sbin/initqueue</command>.
+        <para>Now the main loop of <command>99base/init</command> begins. Here we loop until <command>udev</command> has settled and all scripts in <filename>initqueue/finished</filename> returned true. In this loop there are three hooks, where scripts can be inserted by calling <command>/sbin/initqueue</command>.
  </para>
         <section>
           <title>Initqueue</title>
@@ -582,6 +582,10 @@ Common used functions are in <filename>dracut-lib.sh</filename>, which can be so
           <title>Initqueue settled</title>
           <para>This hooks gets executed every time <command>udev</command> has settled.</para>
         </section>
+        <section>
+          <title>Initqueue timeout</title>
+          <para>This hooks gets executed, when the main loop counter becomes half of the rd.retry counter.</para>
+        </section>
         <section>
           <title>Initqueue finished</title>
           <para>This hook is called after <command>udev</command> has settled and if all scripts herein return <errorcode>0</errorcode> the main loop will be ended.</para>
@@ -621,7 +625,7 @@ Common used functions are in <filename>dracut-lib.sh</filename>, which can be so
       <para><function>install()</function>:</para>
       <programlisting>inst_hook cmdline 20 &quot;$moddir/parse-insmodpost.sh&quot;
 inst_simple &quot;$moddir/insmodpost.sh&quot; /sbin/insmodpost.sh</programlisting>
-      <para>The <filename>pase-instmodpost.sh</filename> parses the kernel command line for a argument <envar>rd.driver.post</envar>, blacklists the module from being autoloaded and installs the hook <filename>insmodpost.sh</filename> in the <filename>initqueue-settled</filename>.</para>
+      <para>The <filename>pase-instmodpost.sh</filename> parses the kernel command line for a argument <envar>rd.driver.post</envar>, blacklists the module from being autoloaded and installs the hook <filename>insmodpost.sh</filename> in the <filename>initqueue/settled</filename>.</para>
       <para><filename>parse-insmodpost.sh</filename>:</para>
       <programlisting>for p in $(getargs rd.driver.post=); do
     echo &quot;blacklist $p&quot; &gt;&gt; /etc/modprobe.d/initramfsblacklist.conf
@@ -631,7 +635,7 @@ done
 [ -n &quot;$_do_insmodpost&quot; ] &amp;&amp; /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
 unset _do_insmodpost
 </programlisting>
-      <para><filename>insmodpost.sh</filename>, which is called in the <filename>initqueue-settled</filename> hook will just modprobe the kernel modules specified in all <envar>rd.driver.post</envar> kernel command line parameters. It runs after <command>udev</command> has settled and is only called once (<parameter>--onetime</parameter>).</para>
+      <para><filename>insmodpost.sh</filename>, which is called in the <filename>initqueue/settled</filename> hook will just modprobe the kernel modules specified in all <envar>rd.driver.post</envar> kernel command line parameters. It runs after <command>udev</command> has settled and is only called once (<parameter>--onetime</parameter>).</para>
       <para><filename>insmodpost.sh</filename>:</para>
       <programlisting>. /lib/dracut-lib.sh
 
index b9911966c3776b9fa050fa9731401b5a358ddf14..90128c77d63642d0d18ff37afa96e4763bdc3d6d 100755 (executable)
@@ -212,8 +212,9 @@ getarg 'rd.break=initqueue' 'rdbreak=initqueue' && emergency_shell -n initqueue
 RDRETRY=$(getarg rd.retry 'rd_retry=')
 RDRETRY=${RDRETRY:-20}
 RDRETRY=$(($RDRETRY*2))
-
-i=0
+export RDRETRY
+main_loop=0
+export main_loop
 while :; do
 
     check_finished && break
@@ -265,12 +266,22 @@ while :; do
         fi
     done
 
-    i=$(($i+1))
-    [ $i -gt $RDRETRY ] \
+    if [ $main_loop -gt $(($RDRETRY/2)) ]; then
+       for job in $hookdir/initqueue/timeout/*.sh; do
+            [ -e "$job" ] || break
+            job=$job . $job
+            main_loop=0
+       done
+    fi
+
+    main_loop=$(($main_loop+1))
+    [ $main_loop -gt $RDRETRY ] \
         && { flock -s 9 ; emergency_shell "No root device \"$root\" found"; } 9>/.console_lock
 done
 unset job
 unset queuetriggered
+unset main_loop
+unset RDRETRY
 
 # reset cdrom polling
 for cdrom in /sys/block/sr*; do
index a1cd1d6cef51927a17e8fc605a1d5bc4a4d7a346..21b1c61993bcc325683ea6b6cf0e7468bfa7e83a 100755 (executable)
@@ -19,6 +19,8 @@ while [ $# -gt 0 ]; do
             qname="/settled";;
         --finished)
             qname="/finished";;
+       --timeout)
+           qname="/timeout";;
         --unique)
             unique="yes";;
         --name)
index 40c94f6af3a87839b8b380f5f21e1fd327c6867f..f6dc92083b0b2c9f4ff32230cc7b860e27761cd5 100755 (executable)
@@ -29,7 +29,7 @@ install() {
     mkdir -m 0755 -p ${initdir}/lib/dracut
     mkdir -m 0755 -p ${initdir}/lib/dracut/hooks
     for _d in $hookdirs emergency \
-        initqueue initqueue/finished initqueue/settled; do
+        initqueue initqueue/timeout initqueue/finished initqueue/settled; do
         mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
     done