From a9f17210c753fbb659f4bff41170ba4d91c2634f0388f78d690d97c9a16827c8 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Sat, 21 Jun 2014 11:15:08 +0000 Subject: [PATCH] Accepting request 238198 from home:jeff_mahoney:branches:Base:System - grub2: use stat instead of udevadm for partition lookup (bnc#883635) * Added grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch OBS-URL: https://build.opensuse.org/request/show/238198 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=91 --- ...tead-of-udevadm-for-partition-lookup.patch | 32 +++++++++++++++++++ grub2.changes | 6 ++++ grub2.spec | 2 ++ 3 files changed, 40 insertions(+) create mode 100644 grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch diff --git a/grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch b/grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch new file mode 100644 index 0000000..5b226b6 --- /dev/null +++ b/grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch @@ -0,0 +1,32 @@ +From: Jeff Mahoney +Subject: grub2: use stat instead of udevadm for partition lookup +References: bnc#883635 + +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 +--- + grub-core/osdep/linux/hostdisk.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/grub-core/osdep/linux/hostdisk.c ++++ b/grub-core/osdep/linux/hostdisk.c +@@ -105,6 +106,13 @@ sysfs_partition_path (const char *dev, c + 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"; diff --git a/grub2.changes b/grub2.changes index 6faaac4..a9661ab 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Jun 20 19:50:28 UTC 2014 - jeffm@suse.com + +- grub2: use stat instead of udevadm for partition lookup (bnc#883635) + * Added grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch + ------------------------------------------------------------------- Tue Apr 15 08:36:46 UTC 2014 - tchvatal@suse.com diff --git a/grub2.spec b/grub2.spec index 1792a9b..ea9a18c 100644 --- a/grub2.spec +++ b/grub2.spec @@ -173,6 +173,7 @@ Patch223: grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-sp Patch224: grub2-ppc64-build-ppc64-32bit.patch Patch225: grub2-ppc64-qemu.patch Patch226: grub2-ppc64le-timeout.patch +Patch227: grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch Requires: gettext-runtime %if 0%{?suse_version} >= 1140 @@ -362,6 +363,7 @@ mv po/grub.pot po/%{name}.pot %patch224 -p1 %patch225 -p1 %patch226 -p1 +%patch227 -p1 # Generate po/LINGUAS for message catalogs ... ./linguas.sh