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=20251104; t=1792577452; x=1793182252; darn=lists.altlinux.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5s4+3lTLcvSCxABQfPf5aChiTV5pXvstrV61phkWdG0=; b=Z2uqOgUBrvjL8LXQvJAIaclV0qQQDBBBNPEW3eO23wg6Uv2SbvkgJf7q4RTSSWim+u 8wkpWtX4NjRiJcpyE7R7TpKSu4u1FhsxtEpR6phbGd50QbxwFQeq1CsBPR5KR32TXV8E lppetWqljeWS0mmdzUqnF3LjuauDu9yxqM5K+/JITBycJ4AmYPSE3M/xeZDsS/ENQUMv JNEJ37frlPXfIF2rMbIulkHSAw/I2Vy8gAhD+XeD6uaMpPPZDKs/i+bUuySn9TFVTaJR zlpDVxGayih5U3Cl72A6GBvTtYSBLhcfNE/xeDZVKvoRQ02Q/40c5IXonbcAEqm/pXBZ XpYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792577452; x=1793182252; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5s4+3lTLcvSCxABQfPf5aChiTV5pXvstrV61phkWdG0=; b=K7H2f2/Ra1P5USQOFK4xJz3LAiotWF45SU8yCqm1ydpmNy5h9KOIEWFPByIApEnxg6 N5z8dEi0G4evLNS81Ta9L8oR0UGGnKbxVZZxSDTyToUQhIfI+935z4yhHU8eOf1eEs6I slFQHu++sQdYXolKfecHNN6335nN0uRK+/lVtdfjM4m8KL0cLSIDfowaNtoe/QipIaC+ TNxV5cKjSGYSQ1hUYnW8RT1yGhOGJWa1NGvr7io/NoARfg6aRCyojM5rkJvKWuNMfXbJ Ja3US5fiHie1CJZtX2wcnG3WdW/WMtCVKWKYQl15gp6ZaIa4WIG9btsHzpKPE7vGoQeN rPTg== X-Gm-Message-State: AFq9FYKokXs2J8JSmWmms57/1v070S20wPbTsCs190aH+xqHxVQkFOFz EovHKaXIirrChfmT9sJkOrUqLFBTUVWLA1V4uKqA5JNFD99jl4egN3lUQREEeg== X-Gm-Gg: AYBFou3gbDfqvObj5a6c33EURS9BdL1jYVENURiPs3j2T0Sea0GsaJ61nuVqF5E+dcQ eX4q5j6ws3nK9Nnf8fxolLFOVY5kC1TGh9e5EoVeAo0sxfhrM+fb5vI0KzBWMlegIrRB+M3mAmN 9NLV7a0e1EoHChVajt0YRbFOOpQzUkZHzJ2Hh/lHQB1chpmnqNY0XHxJ5+3Q3U7xMHLEfCI8Ifr //BglYVa/AtErm526velxSybvQYmO9aGfmte7wpyvwzzRnodisDgJjktUiWZjNUM0fuDkvTVJZP +AKM+u4x2NpttZ5U6/2pt4yKKW7Fk9QS5PYkG01hgbddmHABEyqHqvdk53hbrrj9SZi7Q1qX2J1 eq9IIXyLR+OmWXyDDNXcZrjYPgPnTAKtGuPGekTNF4M+mkfmOIx9Ay2MWCkvmD/yhIQGHxLfMWO fArYw166VaDoHq/e2i7eLrfqStloZLI9gROav5LVS5mlNFdBAT/cyKg+UuAg9ab6FK5SdTT/zs7 FAxWcDQ9kcILl3Zo6yFZcuu1aGGR7CG4ekvedCm5T129g/NxEwrBrsK+yRzIo3KzVBk2/12BpHU df4xJO8elhh+Kmt/uUXhSNAo4IMXlm9+VA== X-Received: by 2002:a05:600c:4ecf:b0:4a1:e7ce:107b with SMTP id 5b1f17b1804b1-4a1fd8a3fdemr34240025e9.2.1792577451770; Wed, 21 Oct 2026 03:10:51 -0700 (PDT) From: Alexey Gladkov To: make-initrd@lists.altlinux.org Date: Wed, 21 Oct 2026 12:10:27 +0200 Message-ID: <20261021101032.278166-1-gladkov.alexey@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <5471301a-a86f-4d22-b606-689eff804df8@gmail.com> References: <5471301a-a86f-4d22-b606-689eff804df8@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [make-initrd] [PATCH] runtime: Freeze rootdelay countdown while paused 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: Wed, 21 Oct 2026 10:10:55 -0000 Archived-At: List-Archive: The rootdelay service tracks device discovery timeouts against an absolute deadline timestamp. When rootdelay_pause is invoked (e.g., during fsck filesystem checks), the deadline was left unchanged while boottime continued to advance. When unpaused, the time spent waiting on the blocking operation was counted against the rootdelay allowance, often causing the timeout to expire immediately. Fix this by recording the timestamp when pausing and shifting the deadline forward by the elapsed pause duration upon unpause. Atomic mkdir and directory renaming are used to eliminate time-of-check to time-of-use races between concurrent callers. If the timer is reset while paused, advance the recorded pause start timestamp to prevent adding duplicate time. Signed-off-by: Alexey Gladkov --- Ты имеешь в виду что-то типа вот такого поведения ? --- features/runtime/data/bin/initrd-sh-functions | 59 ++++++++++++++++--- features/runtime/data/sbin/rootdelayd | 4 +- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/features/runtime/data/bin/initrd-sh-functions b/features/runtime/data/bin/initrd-sh-functions index a69eabee..be8d7182 100644 --- a/features/runtime/data/bin/initrd-sh-functions +++ b/features/runtime/data/bin/initrd-sh-functions @@ -126,17 +126,57 @@ write_atomic() fi } -_rootdelay_pause=/.initrd/rootdelay/pause -_rootdelay_timestamp=/.initrd/rootdelay/deadline +current_seconds() +{ + local __v= + __v="$("${TIMESTAMP:-timestamp}" boottime raw 2>/dev/null)" ||: + __v="${__v%.*}" + eval "$1=\"\$__v\"" +} + +_rootdelay_pause="${_rootdelay_pause:-/.initrd/rootdelay/pause}" +_rootdelay_timestamp="${_rootdelay_timestamp:-/.initrd/rootdelay/deadline}" rootdelay_pause() { - mkdir -p "$_rootdelay_pause" + local now + + mkdir -p -- "${_rootdelay_pause%/*}" + if ! mkdir "$_rootdelay_pause" 2>/dev/null; then + return 0 + fi + + current_seconds now + write_atomic "$_rootdelay_pause/start" printf '%s\n' "$now" } rootdelay_unpause() { - rm -rf "$_rootdelay_pause" + local pause_dir="$_rootdelay_pause.$$.$BASHPID" + local pause_start now paused_duration deadline + + if ! mv "$_rootdelay_pause" "$pause_dir" 2>/dev/null; then + return 0 + fi + + if [ -f "$pause_dir/start" ]; then + readline pause_start "$pause_dir/start" + + if [ -n "$pause_start" ] && [ -f "$_rootdelay_timestamp" ]; then + current_seconds now + paused_duration=$(( $now - $pause_start )) + + if [ "$paused_duration" -gt 0 ]; then + readline deadline "$_rootdelay_timestamp" + + if [ -n "$deadline" ] && [ "$deadline" -gt 0 ]; then + rootdelay_set_deadline "$(( $deadline + $paused_duration ))" + fi + fi + fi + fi + + rm -rf "$pause_dir" } rootdelay_paused() @@ -153,11 +193,16 @@ rootdelay_set_deadline() rootdelay_reset_timer() { local now="${1-}" + if [ -z "$now" ]; then - now="$(timestamp boottime raw)" - now="${now%.*}" + current_seconds now + fi + + rootdelay_set_deadline "$(( $now + ${ROOTDELAY:-0} ))" + + if [ -f "$_rootdelay_pause/start" ]; then + write_atomic "$_rootdelay_pause/start" printf '%s\n' "$now" fi - rootdelay_set_deadline "$(( $now + $ROOTDELAY ))" } initrd_features=/.initrd/features diff --git a/features/runtime/data/sbin/rootdelayd b/features/runtime/data/sbin/rootdelayd index 5fa21f07..4b11e5a4 100755 --- a/features/runtime/data/sbin/rootdelayd +++ b/features/runtime/data/sbin/rootdelayd @@ -71,9 +71,9 @@ while :; do continue fi + current_seconds now + first_iter= - now="$(timestamp boottime raw)" - now="${now%.*}" consmsg="/.initrd/rootdelay/message" if [ ! -f "$_rootdelay_timestamp" ]; then -- 2.56.0