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 07BB7138346 for ; Sun, 5 Jan 2020 21:18:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1886EE08B1; Sun, 5 Jan 2020 21:18:32 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 F0B1AE08B1 for ; Sun, 5 Jan 2020 21:18:31 +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 1DEA434DDDD for ; Sun, 5 Jan 2020 21:18:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B705C3D for ; Sun, 5 Jan 2020 21:18:29 +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: <1578257836.ea892515ef3a46171d288d9c119defedf8dbee28.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.defaults defaults/initrd.scripts X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: ea892515ef3a46171d288d9c119defedf8dbee28 X-VCS-Branch: master Date: Sun, 5 Jan 2020 21:18:29 +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: dc9799d4-79f0-44ab-90ff-040b4b1400f4 X-Archives-Hash: 02a86d595d60b29d1a34495fa5dffb04 commit: ea892515ef3a46171d288d9c119defedf8dbee28 Author: Thomas Deutschmann gentoo org> AuthorDate: Sun Jan 5 20:45:51 2020 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sun Jan 5 20:57:16 2020 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=ea892515 initrd.scripts: modules_scan(): Cache found rootfs Calling findfs() isn't a cheap operation especially when slow media like optical drives are involved. WIth this change, a statefile (GK_ROOTFS_DETECTED_STATEFILE) will be created when rootfs was found which will allow us to skip further findfs() calls when present. Link: https://forums.gentoo.org/viewtopic-t-1105908.html Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.defaults | 1 + defaults/initrd.scripts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index 268a7be..198800b 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -90,6 +90,7 @@ GK_NET_TIMEOUT_DHCP=10 GK_NET_TIMEOUT_INTERFACE=10 GK_PROMPT_FILE='/tmp/current_prompt' GK_PROMPT_TIMEOUT=0 +GK_ROOTFS_DETECTED_STATEFILE="/tmp/rootfs.detected" GK_SHELL_LOCKFILE='/tmp/rescueshell.lock' GK_SSHD_LOCKFILE='/tmp/remote-rescueshell.lock' GK_SSHD_PIDFILE='/var/run/dropbear.pid' diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 4b43d33..73cd94c 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -100,9 +100,16 @@ modules_scan() { then if [ "${smart_loading}" = "yes" ] then - _root_dev=$(findfs "${REAL_ROOT}" 2>/dev/null) + if [ ! -f "${GK_ROOTFS_DETECTED_STATEFILE}" ] + then + _root_dev=$(findfs "${REAL_ROOT}" 2>/dev/null) + if [ $? -eq 0 ] && [ -n "${_root_dev}" ] && [ -b "${_root_dev}" ] + then + echo "${_root_dev}" > "${GK_ROOTFS_DETECTED_STATEFILE}" + fi + fi - if [ $? -eq 0 ] && [ -n "${_root_dev}" ] && [ -b "${_root_dev}" ] + if [ -f "${GK_ROOTFS_DETECTED_STATEFILE}" ] then log_msg "${root_dev_found}" printf "%b" "${root_dev_found}"