From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 64FF0138334 for ; Tue, 16 Jul 2019 16:36:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5C09EE0826; Tue, 16 Jul 2019 16:36:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2ECE3E0826 for ; Tue, 16 Jul 2019 16:36:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CCEA4347CE3 for ; Tue, 16 Jul 2019 16:36:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5875B73B for ; Tue, 16 Jul 2019 16:36:07 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1563294488.c4616417e5c827a1ddf4daa89de82922fecda904.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.defaults defaults/linuxrc X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: c4616417e5c827a1ddf4daa89de82922fecda904 X-VCS-Branch: master Date: Tue, 16 Jul 2019 16:36:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6c9f43c0-84c3-48f5-bc90-99f1e7131916 X-Archives-Hash: 989b972d217b5f40bd2088b99bf622e1 commit: c4616417e5c827a1ddf4daa89de82922fecda904 Author: Thomas Deutschmann gentoo org> AuthorDate: Tue Jul 16 16:06:43 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Tue Jul 16 16:28:08 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c4616417 linuxrc: Change ROOTDELAY handling Before this change we converted $ROOTDELAY into microseconds and decremented that value on each loop iteration. Once that value was <=0 we threw a timeout. Because we substracted a fixed value we didn't take into account that a command from loop could already have taken some time. During testing, in worst case, running with ROOTDELAY=10 and invalid root=UUID= parameter, it was seen that it took up to ~35s instead of 10s before linuxrc prompted for new root value. With this change, we now set a timeout based on current time in seconds + ROOTDELAY. Loop will end if current time is >= timeout. In addition, ROOTDELAY default value was changed from 1 to 5. Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.defaults | 2 +- defaults/linuxrc | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index 7d941d5..fbbd214 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -60,7 +60,7 @@ REAL_ROOT='' CONSOLE='/dev/console' NEW_ROOT='/newroot' no_umounts='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino' -ROOTDELAY=1 +ROOTDELAY=5 CDROOT='0' CDROOT_DEV='' CDROOT_TYPE='auto' diff --git a/defaults/linuxrc b/defaults/linuxrc index 4706055..6b69a13 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -593,8 +593,9 @@ then fi # Determine root device -ROOTDELAY_100MSEC=1 -[ -n "${ROOTDELAY}" ] && ROOTDELAY_100MSEC=$((${ROOTDELAY} * 10)) +let ROOTDELAY_TIMEOUT=$(date +%s)+1 +ROOTDELAY_TIME_WAITED=0 +[ -n "${ROOTDELAY}" -a ${ROOTDELAY} -gt 0 ] && let ROOTDELAY_TIMEOUT=${ROOTDELAY_TIMEOUT}+${ROOTDELAY}-1 while true do good_msg_n 'Determining root device ...' @@ -602,7 +603,7 @@ do while [ "${got_good_root}" != '1' ] do # Start of sleep loop waiting on root - while [ ${ROOTDELAY_100MSEC} -ge 0 -a "${got_good_root}" != '1' ] + while [ "${got_good_root}" != '1' -a $(date +%s) -le ${ROOTDELAY_TIMEOUT} ] do case "${REAL_ROOT}" in LABEL=*|UUID=*|PARTUUID=*) @@ -676,6 +677,7 @@ do if [ -b "${REAL_ROOT}" ] then got_good_root=1 + echo good_msg "Detected real_root=${REAL_ROOT}" break fi @@ -684,10 +686,10 @@ do if [ "${got_good_root}" != '1' ] then - let ROOTDELAY_100MSEC=${ROOTDELAY_100MSEC}-1 + let ROOTDELAY_TIME_WAITED=${ROOTDELAY_TIME_WAITED}+1 sleep 0.1s - let ROOTDELAY_100MSEC_MODULO=${ROOTDELAY_100MSEC}%10 + let ROOTDELAY_100MSEC_MODULO=${ROOTDELAY_TIME_WAITED}%10 if [ ${ROOTDELAY_100MSEC_MODULO} = 0 ] then printf "." @@ -695,13 +697,13 @@ do fi done # End of sleep loop waiting on root - if [ ${ROOTDELAY_100MSEC} -le 0 ] + if [ $(date +%s) -gt ${ROOTDELAY_TIMEOUT} ] then echo fi # Check for a block device or /dev/nfs or zfs encryption - if [ -n "${REAL_ROOT}" ] && [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ] || [ "${ROOTFSTYPE}" = "zfs" ] + if [ -n "${REAL_ROOT}" ] && [ "${REAL_ROOT}" = "/dev/nfs" ] || [ "${ROOTFSTYPE}" = "zfs" ] || [ -b "${REAL_ROOT}" ] then if [ "${ROOTFSTYPE}" = "zfs" ] then @@ -803,6 +805,8 @@ do then bad_msg "Block device ${REAL_ROOT} is not a valid root device ..." prompt_user "REAL_ROOT" "root block device" + ROOTDELAY_TIME_WAITED=0 + let ROOTDELAY_TIMEOUT=$(date +%s)+1 fi done # End determine root device