All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: Daniel Kiper <daniel.kiper@oracle.com>, Petr Vorel <pvorel@suse.cz>
Cc: grub-devel@gnu.org, Michael Chang <mchang@suse.com>,
	Mike Gilbert <floppym@gentoo.org>
Subject: Re: [PATCH 2/2] grub2: use stat instead of udevadm for partition lookup
Date: Tue, 13 Jul 2021 14:03:39 -0400	[thread overview]
Message-ID: <79ce3257-5267-6ac4-0a8c-a32221fceb91@suse.com> (raw)
In-Reply-To: <20210713174825.psrixhsnnoii3ybk@tomti.i.net-space.pl>


[-- Attachment #1.1: Type: text/plain, Size: 2268 bytes --]

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 <jeffm@suse.com>
>>
>> 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 <jeffm@suse.com>
>> [ pvorel: include grub/osdep/major.h ]
>> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>> ---
>>  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 <grub/misc.h>
>>  #include <grub/i18n.h>
>>  #include <grub/list.h>
>> +#include <grub/osdep/major.h>
>>
>>  #include <stdio.h>
>>  #include <stdlib.h>
>> @@ -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 <dev>' 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.

-Jeff

-- 
Jeff Mahoney
Director, SUSE Labs Data & Performance


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2021-07-13 20:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 15:55 [PATCH 0/2] linux: use stat instead of udevadm for partition lookup + cleanup Petr Vorel
2021-07-08 15:55 ` [PATCH 1/2] osdep: Introduce major.h and use it Petr Vorel
2021-07-13 17:36   ` Daniel Kiper
2021-07-13 19:07     ` Petr Vorel
2021-07-14  6:54       ` Petr Vorel
2021-07-14 12:55         ` Daniel Kiper
2021-07-14 14:42           ` Petr Vorel
2021-07-14 14:47             ` Petr Vorel
2021-07-08 15:55 ` [PATCH 2/2] grub2: use stat instead of udevadm for partition lookup Petr Vorel
2021-07-13  9:25   ` Paul Menzel
2021-07-13 10:52     ` Petr Vorel
2021-07-14  6:24       ` Michael Chang
2021-07-14  6:45         ` Petr Vorel
2021-07-14  4:16     ` Michael Chang
2021-07-13 17:48   ` Daniel Kiper
2021-07-13 18:03     ` Jeff Mahoney [this message]
2021-07-13 19:10       ` Petr Vorel
2021-07-14 13:00         ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79ce3257-5267-6ac4-0a8c-a32221fceb91@suse.com \
    --to=jeffm@suse.com \
    --cc=daniel.kiper@oracle.com \
    --cc=floppym@gentoo.org \
    --cc=grub-devel@gnu.org \
    --cc=mchang@suse.com \
    --cc=pvorel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.