From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1m3Nnr-0000nE-Fs for mharc-grub-devel@gnu.org; Tue, 13 Jul 2021 15:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3Nnp-0000mA-HB for grub-devel@gnu.org; Tue, 13 Jul 2021 15:10:45 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:51902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3Nnn-0002DF-P3 for grub-devel@gnu.org; Tue, 13 Jul 2021 15:10:45 -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-out1.suse.de (Postfix) with ESMTPS id 134CE2295A; Tue, 13 Jul 2021 19:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1626203442; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGRj6YEw7sHc6k9iWPLpyRDuEDYKxvwSlww06B5LGx8=; b=2hovX/lg+abj7mKGMDWBCBNUenqwuCVxQ70YIlV+6rsb2HxH6mnEXjoru/GKfCLxHwFLQg qhSSu+tc5u8MlcJmRQHVz9klJhMIAIbEX1yZ6rq5EXH37WAAnDqrsLZ1zqhcNoLiYlab8i FjJ76fDtx3p51Kf0jbQ2VMiBgmrgTbc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1626203442; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGRj6YEw7sHc6k9iWPLpyRDuEDYKxvwSlww06B5LGx8=; b=BeC+bWMKZRdA/EUqPsfpueg0PNQ4SxdSiDUNz7+4Rt/DhLKNfCnlMlD4SL3+dsBYNKG78S gDQlATOBPWjluJDQ== 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 97B1B13AFE; Tue, 13 Jul 2021 19:10:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CHyfIzHl7WABawAAMHmgww (envelope-from ); Tue, 13 Jul 2021 19:10:41 +0000 Date: Tue, 13 Jul 2021 21:10:39 +0200 From: Petr Vorel To: Jeff Mahoney Cc: Daniel Kiper , grub-devel@gnu.org, Michael Chang , Mike Gilbert Subject: Re: [PATCH 2/2] grub2: use stat instead of udevadm for partition lookup Message-ID: Reply-To: Petr Vorel References: <20210708155558.26466-1-pvorel@suse.cz> <20210708155558.26466-3-pvorel@suse.cz> <20210713174825.psrixhsnnoii3ybk@tomti.i.net-space.pl> <79ce3257-5267-6ac4-0a8c-a32221fceb91@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <79ce3257-5267-6ac4-0a8c-a32221fceb91@suse.com> Received-SPF: pass client-ip=195.135.220.28; envelope-from=pvorel@suse.cz; helo=smtp-out1.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: Tue, 13 Jul 2021 19:10:45 -0000 Hi all, > On 7/13/21 1:48 PM, Daniel Kiper wrote: > > On Thu, Jul 08, 2021 at 05:55:58PM +0200, Petr Vorel wrote: > >> 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); > > Missing space between "stat" and "(". > >> + if (ret == 0 && S_ISBLK(st.st_mode)) > > Same for S_ISBLK... > >> + return xasprintf ("/sys/dev/block/%u:%u/%s", > >> + major (st.st_rdev), minor (st.st_rdev), entry); > >> argv[0] = "udevadm"; > >> argv[1] = "info"; > > Do we really need udevadm fallback mechanism? If something went wrong > > here for us I do not expect it will work for udevadm either. > I suspect not. 'udevadm info --query path --name ' does > essentially the same thing but with many more steps and the cost > starting an external program for every block device. I left it in with > the assumption that it was probably there for a reason and perhaps > udevadm on early udev systems did something more special than just doing > stat + sysfs path building. I didn't spend any time on validating that > assumption. As it'd be wort to remove udevadm fallback, I'll stop being lazy and setup VM to test. Kind regards, Petr > -Jeff