[make-initrd] [PATCH 3/3] feature/kickstart: Reset rootdelay timer after kickstart
Alexey Gladkov
gladkov.alexey at gmail.com
Thu May 4 16:42:52 MSK 2023
If the rootdelay timer has started counting down, then after poll is
unpaused, a timeout may occur. This is because the rootdelay remembers
the time and if the kickstart took a long time it will timeout the next
time the rootdelay is checked.
To avoid this we reset the timer before we unpause poll.
Signed-off-by: Alexey Gladkov <gladkov.alexey at gmail.com>
---
data/bin/initrd-sh-functions | 8 ++++++++
data/lib/uevent/handlers/poll/400-rootdelay | 13 ++++++-------
features/kickstart/data/etc/rc.d/init.d/kickstart | 3 +++
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/data/bin/initrd-sh-functions b/data/bin/initrd-sh-functions
index 1f2c1a8d..f33885ba 100644
--- a/data/bin/initrd-sh-functions
+++ b/data/bin/initrd-sh-functions
@@ -106,6 +106,7 @@ readline()
}
_rootdelay_pause=/.initrd/rootdelay/pause
+_rootdelay_timestamp=/.initrd/rootdelay/deadline
rootdelay_pause()
{
@@ -122,6 +123,13 @@ rootdelay_paused()
[ -d "$_rootdelay_pause" ]
}
+rootdelay_reset_timer()
+{
+ local now
+ now="$(date +'%s')"
+ echo $(( $now + $ROOTDELAY )) > "$_rootdelay_timestamp"
+}
+
initrd_features=/.initrd/features
has_feature()
diff --git a/data/lib/uevent/handlers/poll/400-rootdelay b/data/lib/uevent/handlers/poll/400-rootdelay
index e7089956..cac86622 100755
--- a/data/lib/uevent/handlers/poll/400-rootdelay
+++ b/data/lib/uevent/handlers/poll/400-rootdelay
@@ -23,31 +23,30 @@ fi
first_iter=
now="$(date +'%s')"
-timestamp="/.initrd/rootdelay/deadline"
consmsg="/.initrd/rootdelay/message"
-if [ ! -f "$timestamp" ]; then
+if [ ! -f "$_rootdelay_timestamp" ]; then
first_iter=1
deadline=$(( $now + $ROOTDELAY ))
- mkdir -p -- "${timestamp%/*}"
- echo $deadline > "$timestamp"
+ mkdir -p -- "${_rootdelay_timestamp%/*}"
+ echo $deadline > "$_rootdelay_timestamp"
else
- read -r deadline < "$timestamp"
+ read -r deadline < "$_rootdelay_timestamp"
fi
deadline="${deadline:-$now}"
delay=$(( $deadline - $now ))
if rootdelay_paused; then
- echo $(( $now + $delay )) > "$timestamp"
+ echo $(( $now + $delay )) > "$_rootdelay_timestamp"
exit 0
fi
if [ "$delay" -le 0 ]; then
if ! resume_checked; then
set_resume_checked
- echo $(( $now + $ROOTDELAY )) > "$timestamp"
+ echo $(( $now + $ROOTDELAY )) > "$_rootdelay_timestamp"
exit 0
fi
diff --git a/features/kickstart/data/etc/rc.d/init.d/kickstart b/features/kickstart/data/etc/rc.d/init.d/kickstart
index e36b9470..ef01bcd6 100755
--- a/features/kickstart/data/etc/rc.d/init.d/kickstart
+++ b/features/kickstart/data/etc/rc.d/init.d/kickstart
@@ -23,11 +23,14 @@
if [ -s "$KSFILE" ]; then
. uevent-sh-functions
+ . initrd-sh-functions
mkdir -p -- "$uevent_confdb/queue/pause/poll"
kickstart -v "$KSFILE"
+ rootdelay_reset_timer
+
rmdir -- "$uevent_confdb/queue/pause/poll"
rmdir -- "$uevent_confdb/queue/pause/udev"
rmdir -- "$uevent_confdb/queue/pause/md-raid-member"
--
2.33.7
More information about the Make-initrd
mailing list