From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683207831; x=1685799831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o6KWrGeA/GL3CeZ8kmIFum/AAHbJ1MggkZPs3Z1EY0U=; b=j+iVWuZS6dSzrSODcAB794OtW5BB8u/vMlWM7sGaYunQnlMxFDcpBO2isHyfLCVWiF v70Wk63E5nEJhD1NKNsdGShX5YBxBhM6LsHtslFPHhQlMqoYaeEH1Yf1xmkAH0+dIJk9 +L0KzVpuB/TpHZKknMyf8fY/KdHKgFnCKiqArNu9aRXfWIVD9XB8LmRhwZ30hCM3oEad uShGYTDlv6X5TR9I4a41NUtfuepz18ndZE2sl0LNAyVksN7XGnPJ+UbjPTtKebu4XZ2N bLOr1JHkORIX8LkmMtXNTC3LH5+IYfgUFWcLO3FrpMK9SmS3+z+V83DMOvjiB2VC9Bc6 uauA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683207831; x=1685799831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o6KWrGeA/GL3CeZ8kmIFum/AAHbJ1MggkZPs3Z1EY0U=; b=PjRBD0rWZgDu61vfhmq+u52EEgr9QKm15PtZ9eGGo1ot42G5AYel++aag0OIxURJ27 6jrhSzcLv16sT8Rz9w77ViQHM7qGWRDxlMLkc4zYrJz2qOOAiIICZ0rXsgsvnJV1dKjD 9Ki2t3o6m3ja0w9W2NiiGNPos0xi5EwI2u60LQBe9cMXJNE8N4BdZl1dIME5ebsD3huU js4NCMnYaf1SnuGBlJt4gv+ozR20nrKQak/vtVQrpCLmtar+T1ds1WIX+4CiS9WcWqKZ iTy18sQhgmQ6BPBepDhw3Om3czgj8QeJYT5I+stB1gsMRUV0jqVLKNzrASy8eP0klykK UmcA== X-Gm-Message-State: AC+VfDwhqCYDO3gj0+t5WZul8rLrqOvCS2OiXGIGtFEsDv9Lc6Ki8FGf pPjPcnX2K6x32Wi0Oc6uP+a3ow3uxUI= X-Google-Smtp-Source: ACHHUZ7M7kMXGqcmV7SqR23kdyaxsCNRc8ReGTkBrrTaJe+eUOGnzmyGU1QJCrX3jENd9JYV8znhQA== X-Received: by 2002:a5d:5382:0:b0:2ef:1088:1100 with SMTP id d2-20020a5d5382000000b002ef10881100mr2237729wrv.52.1683207831200; Thu, 04 May 2023 06:43:51 -0700 (PDT) From: Alexey Gladkov To: make-initrd@lists.altlinux.org Date: Thu, 4 May 2023 15:42:51 +0200 Message-Id: <5c76e1048e4fd51fbb1671a9be9677939ec38bd3.1683200226.git.gladkov.alexey@gmail.com> X-Mailer: git-send-email 2.33.7 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [make-initrd] [PATCH 2/3] Replace polld by uevent queue X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2023 13:43:56 -0000 Archived-At: List-Archive: 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 --- 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