From: Alexey Gladkov <gladkov.alexey@gmail.com>
To: make-initrd@lists.altlinux.org
Subject: [make-initrd] [PATCH 2/3] Replace polld by uevent queue
Date: Thu, 4 May 2023 15:42:51 +0200
Message-ID: <5c76e1048e4fd51fbb1671a9be9677939ec38bd3.1683200226.git.gladkov.alexey@gmail.com> (raw)
In-Reply-To: <cover.1683200226.git.gladkov.alexey@gmail.com>
Since uevent has become parallel and faster, we can return the polld
functionality back to uevent as a separate queue.
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
---
data/etc/rc.d/init.d/poll | 25 ++++++-----
data/lib/uevent/each/post/.gitignore | 0
data/lib/uevent/each/post/system-bootable | 4 --
data/lib/uevent/extenders/.gitignore | 0
data/lib/uevent/handlers/poll/100-extenders | 22 +++++++++
data/lib/uevent/handlers/poll/300-boot-method | 29 ++++++++++++
.../poll/400-rootdelay} | 0
data/sbin/polld | 45 -------------------
data/sbin/process-boot-method | 16 -------
.../kickstart/data/etc/rc.d/init.d/kickstart | 10 ++---
10 files changed, 68 insertions(+), 83 deletions(-)
create mode 100644 data/lib/uevent/each/post/.gitignore
delete mode 100755 data/lib/uevent/each/post/system-bootable
create mode 100644 data/lib/uevent/extenders/.gitignore
create mode 100755 data/lib/uevent/handlers/poll/100-extenders
create mode 100755 data/lib/uevent/handlers/poll/300-boot-method
rename data/lib/uevent/{extenders/100-rootdelay => handlers/poll/400-rootdelay} (100%)
delete mode 100755 data/sbin/polld
delete mode 100755 data/sbin/process-boot-method
diff --git a/data/etc/rc.d/init.d/poll b/data/etc/rc.d/init.d/poll
index 8c5e498b..6901f830 100755
--- a/data/etc/rc.d/init.d/poll
+++ b/data/etc/rc.d/init.d/poll
@@ -14,22 +14,23 @@
. /.initrd/initenv
. /etc/init.d/template
+. uevent-sh-functions
-NAME=polld
-PIDFILE="/var/run/$NAME.pid"
-ARGS="--lockfile $LOCKFILE --pidfile $PIDFILE --name $NAME --displayname $NAME"
+start()
+{
+ rmdir -- "$uevent_confdb/queue/pause/poll" 2>/dev/null ||:
-start() {
- start_daemon --background $ARGS "$NAME"
- RETVAL=$?
- return $RETVAL
+ mkdir -p -- /.initrd/uevent/queues/poll/.tmp
+ event="$(make_event poll)"
+ release_event "periodically" "$event"
+
+ return 0
}
-stop() {
- stop_daemon $ARGS "$NAME"
- RETVAL=$?
- [ ! -f "$PIDFILE" ] || rm -f -- "$PIDFILE"
- return $RETVAL
+stop()
+{
+ mkdir -p -- "$uevent_confdb/queue/pause/poll"
+ return 0
}
switch "${1-}"
diff --git a/data/lib/uevent/each/post/.gitignore b/data/lib/uevent/each/post/.gitignore
new file mode 100644
index 00000000..e69de29b
diff --git a/data/lib/uevent/each/post/system-bootable b/data/lib/uevent/each/post/system-bootable
deleted file mode 100755
index 54a39082..00000000
--- a/data/lib/uevent/each/post/system-bootable
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash -efu
-
-[ "$1" != udev ] ||
- process-boot-method
diff --git a/data/lib/uevent/extenders/.gitignore b/data/lib/uevent/extenders/.gitignore
new file mode 100644
index 00000000..e69de29b
diff --git a/data/lib/uevent/handlers/poll/100-extenders b/data/lib/uevent/handlers/poll/100-extenders
new file mode 100755
index 00000000..2968c666
--- /dev/null
+++ b/data/lib/uevent/handlers/poll/100-extenders
@@ -0,0 +1,22 @@
+#!/bin/bash -eu
+
+. /.initrd/initenv
+
+[ "${RDLOG-}" != 'console' ] &&
+ logfile=/var/log/polld.log ||
+ logfile=/dev/console
+
+exec >"$logfile" 2>&1
+
+. shell-error
+. uevent-sh-functions
+
+message_time=1
+
+export queuedir="$1"
+export QUEUE="${queuedir##*/}"
+
+for bin in "$extendir"/*; do
+ [ ! -x "$bin" ] || "$bin" ||
+ message "$QUEUE: session=$SESSION: extender failed: $bin"
+done
diff --git a/data/lib/uevent/handlers/poll/300-boot-method b/data/lib/uevent/handlers/poll/300-boot-method
new file mode 100755
index 00000000..2057024f
--- /dev/null
+++ b/data/lib/uevent/handlers/poll/300-boot-method
@@ -0,0 +1,29 @@
+#!/bin/bash -eu
+
+. /.initrd/initenv
+
+[ "${RDLOG-}" != 'console' ] &&
+ logfile=/var/log/polld.log ||
+ logfile=/dev/console
+
+exec >"$logfile" 2>&1
+
+method=
+{ read -r method < /etc/initrd/method; } >/dev/null 2>&1 ||:
+
+cd "/lib/initrd/boot/method/$method"
+
+if [ -x ./check ] && ./check; then
+ . shell-error
+ message_time=1
+
+ queuedir="$1"
+ QUEUE="${queuedir##*/}"
+
+ message "$QUEUE: session=$SESSION: $method ready. acting!"
+
+ ./action
+fi
+
+# slow down the busy loop of this queue
+sleep 0.2
diff --git a/data/lib/uevent/extenders/100-rootdelay b/data/lib/uevent/handlers/poll/400-rootdelay
similarity index 100%
rename from data/lib/uevent/extenders/100-rootdelay
rename to data/lib/uevent/handlers/poll/400-rootdelay
diff --git a/data/sbin/polld b/data/sbin/polld
deleted file mode 100755
index 1f6b05b3..00000000
--- a/data/sbin/polld
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash -eu
-
-. shell-error
-. shell-signal
-
-. /.initrd/initenv
-. uevent-sh-functions
-
-message_time=1
-pidfile="/var/run/$PROG.pid"
-logfile="/var/log/$PROG.log"
-
-exit_handler()
-{
- local rc="$?"
- trap - EXIT
- rm -f -- "$pidfile"
- exit $rc
-}
-
-[ "${RDLOG-}" != 'console' ] ||
- logfile=/dev/console
-
-[ ! -f "$pidfile" ] ||
- fatal "already running"
-
-set_cleanup_handler exit_handler
-echo "$$" >"$pidfile"
-
-exec >"$logfile" 2>&1
-message "starting server ..."
-
-while [ -f "$pidfile" ]; do
- for fn in "$extendir"/*; do
- [ -x "$fn" ] || continue
- name="${fn##*/}"
- name="${name#[0-9][0-9][0-9]-}"
-
- "$fn" ||
- message "extender failed: $fn"
- done
-
- process-boot-method ||:
- sleep 1
-done
diff --git a/data/sbin/process-boot-method b/data/sbin/process-boot-method
deleted file mode 100755
index e9d3ecf2..00000000
--- a/data/sbin/process-boot-method
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash -efu
-
-. shell-error
-message_time=1
-
-method=
-{ read -r method < /etc/initrd/method; } >/dev/null 2>&1 ||:
-
-d="/lib/initrd/boot/method/$method"
-c="$d/check"
-
-[ -x "$c" ] && "$c" ||
- exit 0
-
-message "$method ready. acting!"
-"$d/action"
diff --git a/features/kickstart/data/etc/rc.d/init.d/kickstart b/features/kickstart/data/etc/rc.d/init.d/kickstart
index 8d6e09f0..e36b9470 100755
--- a/features/kickstart/data/etc/rc.d/init.d/kickstart
+++ b/features/kickstart/data/etc/rc.d/init.d/kickstart
@@ -22,15 +22,13 @@
KSFILE="/etc/ks.conf.d/$KSFILE"
if [ -s "$KSFILE" ]; then
- cp -f /etc/initrd/method /etc/initrd/method.prev
- echo none > /etc/initrd/method
+ . uevent-sh-functions
- kickstart -v "$KSFILE"
+ mkdir -p -- "$uevent_confdb/queue/pause/poll"
- . uevent-sh-functions
+ kickstart -v "$KSFILE"
+ rmdir -- "$uevent_confdb/queue/pause/poll"
rmdir -- "$uevent_confdb/queue/pause/udev"
rmdir -- "$uevent_confdb/queue/pause/md-raid-member"
-
- cp -f /etc/initrd/method.prev /etc/initrd/method
fi
--
2.33.7
next prev parent reply other threads:[~2023-05-04 13:42 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 13:42 [make-initrd] [PATCH 0/3] Reimplement ueventd Alexey Gladkov
2023-05-04 13:42 ` [make-initrd] [PATCH 1/3] " Alexey Gladkov
2023-05-05 3:08 ` Leonid Krivoshein
2023-05-05 17:02 ` Alexey Gladkov
2023-05-05 4:03 ` Leonid Krivoshein
2023-05-05 17:16 ` Alexey Gladkov
2023-05-05 5:21 ` Leonid Krivoshein
2023-05-05 17:24 ` Alexey Gladkov
2023-05-14 20:12 ` Leonid Krivoshein
2023-05-14 20:45 ` Alexey Gladkov
2023-05-14 20:57 ` Leonid Krivoshein
2023-05-15 8:52 ` Alexey Gladkov
2023-05-14 23:08 ` Leonid Krivoshein
2023-05-15 9:05 ` Alexey Gladkov
2023-05-15 0:47 ` Leonid Krivoshein
2023-05-15 9:12 ` Alexey Gladkov
2023-05-15 4:38 ` Leonid Krivoshein
2023-05-15 10:43 ` Alexey Gladkov
2023-05-18 6:39 ` Leonid Krivoshein
2023-05-18 7:05 ` Alexey Gladkov
2023-05-20 9:00 ` Leonid Krivoshein
2023-05-20 13:18 ` Alexey Gladkov
2023-05-20 15:17 ` Vladimir D. Seleznev
2023-05-20 17:23 ` Leonid Krivoshein
2023-05-20 18:51 ` Alexey Gladkov
2023-05-21 8:53 ` [make-initrd] [PATCH] ueventd: Don't use a epoll timeout when it's not needed Alexey Gladkov
2023-05-22 4:46 ` Leonid Krivoshein
2023-05-22 7:54 ` Alexey Gladkov
2023-05-22 9:19 ` Alexey Gladkov
2023-05-22 7:57 ` [make-initrd] [PATCH 1/2] ueventd: Fix memory leak Alexey Gladkov
2023-05-22 7:57 ` [make-initrd] [PATCH 2/2] ueventd: Change interface rd_asprintf_or_die Alexey Gladkov
2023-05-22 9:36 ` [make-initrd] [PATCH v2] " Alexey Gladkov
2023-05-20 16:37 ` [make-initrd] [PATCH 1/3] ueventd: Simplify call of the queue handler Alexey Gladkov
2023-05-20 16:37 ` [make-initrd] [PATCH 2/3] ueventd: Rename fd_list to fd_handler_list Alexey Gladkov
2023-05-20 16:37 ` [make-initrd] [PATCH 3/3] ueventd: Drop obsolete declarations Alexey Gladkov
2023-05-04 13:42 ` Alexey Gladkov [this message]
2023-05-04 13:42 ` [make-initrd] [PATCH 3/3] feature/kickstart: Reset rootdelay timer after kickstart Alexey Gladkov
2023-05-06 19:45 ` [make-initrd] ueventd: Add a prefix to the logging functions to avoid name collisions Alexey Gladkov
2023-05-06 19:45 ` [make-initrd] ueventd: Allow to configure the log destination Alexey Gladkov
2023-05-06 19:45 ` [make-initrd] ueventd: Pass the program name when initializing the logger Alexey Gladkov
2023-05-06 19:45 ` [make-initrd] ueventd: Rewrite logging function to make it more atomic Alexey Gladkov
2023-05-07 12:48 ` [make-initrd] [PATCH 0/3] Reimplement ueventd Alexey Gladkov
2023-05-13 11:50 ` Alexey Gladkov
2023-05-14 20:15 ` Leonid Krivoshein
2023-05-14 20:49 ` Alexey Gladkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c76e1048e4fd51fbb1671a9be9677939ec38bd3.1683200226.git.gladkov.alexey@gmail.com \
--to=gladkov.alexey@gmail.com \
--cc=make-initrd@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Make-initrd development discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
public-inbox-index make-initrd
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.make-initrd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git