From: Harald Hoyer Date: Fri, 5 Aug 2011 09:53:41 +0000 (+0200) Subject: 99base: add timeout queue X-Git-Tag: 012~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b592c1487740f49fdda2891d5df6663600dd1b6;p=thirdparty%2Fdracut.git 99base: add timeout queue timeout queue is executed after half of the maximum retry count and if jobs are found there, the counter is reset to zero. --- diff --git a/dracut.xml b/dracut.xml index ac78e83bb..13e092a6c 100644 --- a/dracut.xml +++ b/dracut.xml @@ -572,7 +572,7 @@ Common used functions are in dracut-lib.sh, which can be so
Main Loop - Now the main loop of 99base/init begins. Here we loop until udev has settled and all scripts in initqueue-finished returned true. In this loop there are three hooks, where scripts can be inserted by calling /sbin/initqueue. + Now the main loop of 99base/init begins. Here we loop until udev has settled and all scripts in initqueue/finished returned true. In this loop there are three hooks, where scripts can be inserted by calling /sbin/initqueue.
Initqueue @@ -582,6 +582,10 @@ Common used functions are in dracut-lib.sh, which can be so Initqueue settled This hooks gets executed every time udev has settled.
+
+ Initqueue timeout + This hooks gets executed, when the main loop counter becomes half of the rd.retry counter. +
Initqueue finished This hook is called after udev has settled and if all scripts herein return 0 the main loop will be ended. @@ -621,7 +625,7 @@ Common used functions are in dracut-lib.sh, which can be so install(): inst_hook cmdline 20 "$moddir/parse-insmodpost.sh" inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh - The pase-instmodpost.sh parses the kernel command line for a argument rd.driver.post, blacklists the module from being autoloaded and installs the hook insmodpost.sh in the initqueue-settled. + The pase-instmodpost.sh parses the kernel command line for a argument rd.driver.post, blacklists the module from being autoloaded and installs the hook insmodpost.sh in the initqueue/settled. parse-insmodpost.sh: for p in $(getargs rd.driver.post=); do echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf @@ -631,7 +635,7 @@ done [ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh unset _do_insmodpost - insmodpost.sh, which is called in the initqueue-settled hook will just modprobe the kernel modules specified in all rd.driver.post kernel command line parameters. It runs after udev has settled and is only called once (--onetime). + insmodpost.sh, which is called in the initqueue/settled hook will just modprobe the kernel modules specified in all rd.driver.post kernel command line parameters. It runs after udev has settled and is only called once (--onetime). insmodpost.sh: . /lib/dracut-lib.sh diff --git a/modules.d/99base/init b/modules.d/99base/init index b9911966c..90128c77d 100755 --- a/modules.d/99base/init +++ b/modules.d/99base/init @@ -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 diff --git a/modules.d/99base/initqueue b/modules.d/99base/initqueue index a1cd1d6ce..21b1c6199 100755 --- a/modules.d/99base/initqueue +++ b/modules.d/99base/initqueue @@ -19,6 +19,8 @@ while [ $# -gt 0 ]; do qname="/settled";; --finished) qname="/finished";; + --timeout) + qname="/timeout";; --unique) unique="yes";; --name) diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh index 40c94f6af..f6dc92083 100755 --- a/modules.d/99base/module-setup.sh +++ b/modules.d/99base/module-setup.sh @@ -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