Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1m1WNp-0005vo-Tp for mharc-grub-devel@gnu.org; Thu, 08 Jul 2021 11:56:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1WNo-0005pJ-5F for grub-devel@gnu.org; Thu, 08 Jul 2021 11:56:12 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:57612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1WNl-0003Ne-2h for grub-devel@gnu.org; Thu, 08 Jul 2021 11:56:11 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9AF1920212; Thu, 8 Jul 2021 15:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1625759765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a4WGIL5oLjknimEDbOTaDPju2ZOC2Wlf1bxIt/i67NY=; b=dOdxuTBlFn0N9GQHEs+2JMNaF8CO0apnGN6Ae4ruaaK2imz1IBgOgHo/olPZNGMqMkK/4Q 6kIOGOrMxN9udGbPp0GpTErSuUicIsJQNm3lBTIRLPr1UiZjH52BIf4UXTo+8qMH7w6ewX ZYKy8yTcSjz63PxZIkXyTz6LfnMibs8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1625759765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a4WGIL5oLjknimEDbOTaDPju2ZOC2Wlf1bxIt/i67NY=; b=VC04pDkd7wJFfVmzsWH7fPx4qp7eWudyqVpsJP6LT70ifErmvlEM4lb/nBtT1ugMWhkCdg /rZe5fE95VhJnCBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5933113B00; Thu, 8 Jul 2021 15:56:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UCw5ExUg52DlGQAAMHmgww (envelope-from ); Thu, 08 Jul 2021 15:56:05 +0000 From: Petr Vorel To: grub-devel@gnu.org Cc: Jeff Mahoney , Daniel Kiper , Michael Chang , Mike Gilbert , Petr Vorel Subject: [PATCH 2/2] grub2: use stat instead of udevadm for partition lookup Date: Thu, 8 Jul 2021 17:55:58 +0200 Message-Id: <20210708155558.26466-3-pvorel@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210708155558.26466-1-pvorel@suse.cz> References: <20210708155558.26466-1-pvorel@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.29; envelope-from=pvorel@suse.cz; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2021 15:56:12 -0000 From: Jeff Mahoney sysfs_partition_path calls udevadm to resolve the sysfs path for a block device. That can be accomplished by stating the device node and using the major/minor to follow the symlinks in /sys/dev/block/. This cuts the execution time of grub2-mkconfig from 10s to 2s on my system. Signed-off-by: Jeff Mahoney [ pvorel: include grub/osdep/major.h ] Signed-off-by: Petr Vorel --- grub-core/osdep/linux/hostdisk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index da62f924e..43dc4b0ba 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -105,6 +106,13 @@ sysfs_partition_path (const char *dev, const char *entry) char *buf = NULL; size_t len = 0; char *path = NULL; + struct stat st; + int ret; + + ret = stat(dev, &st); + if (ret == 0 && S_ISBLK(st.st_mode)) + return xasprintf ("/sys/dev/block/%u:%u/%s", + major (st.st_rdev), minor (st.st_rdev), entry); argv[0] = "udevadm"; argv[1] = "info"; -- 2.32.0