forked from pool/grub2
Accepting request 828452 from home:michael-chang:branches:Base:System
- Add fibre channel device's ofpath support to grub-ofpathname and search hint to speed up root device discovery (bsc#1172745) * 0001-ieee1275-powerpc-implements-fibre-channel-discovery-.patch * 0002-ieee1275-powerpc-enables-device-mapper-discovery.patch OBS-URL: https://build.opensuse.org/request/show/828452 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=361
This commit is contained in:
parent
575991c6e5
commit
8d758b1bd2
@ -0,0 +1,90 @@
|
||||
From ca30b3c6fd8c848f510445316d0c4a8fca6061ba Mon Sep 17 00:00:00 2001
|
||||
From: Diego Domingos <diegodo@br.ibm.com>
|
||||
Date: Wed, 24 Jun 2020 08:17:18 -0400
|
||||
Subject: [PATCH 1/2] ieee1275/powerpc: implements fibre channel discovery for
|
||||
ofpathname
|
||||
|
||||
grub-ofpathname doesn't work with fibre channel because there is no
|
||||
function currently implemented for it.
|
||||
This patch enables it by prividing a function that looks for the port
|
||||
name, building the entire path for OF devices.
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 48 ++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 48 insertions(+)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index a6153d359..f2bc9fc5c 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -399,6 +399,37 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
}
|
||||
#endif
|
||||
|
||||
+static void
|
||||
+of_fc_port_name(const char *path, const char *subpath, char *port_name)
|
||||
+{
|
||||
+ char *bname, *basepath, *p;
|
||||
+ int fd;
|
||||
+
|
||||
+ bname = xmalloc(sizeof(char)*150);
|
||||
+ basepath = xmalloc(strlen(path));
|
||||
+
|
||||
+ /* Generate the path to get port name information from the drive */
|
||||
+ strncpy(basepath,path,subpath-path);
|
||||
+ basepath[subpath-path-1] = '\0';
|
||||
+ p = get_basename(basepath);
|
||||
+ snprintf(bname,sizeof(char)*150,"%s/fc_transport/%s/port_name",basepath,p);
|
||||
+
|
||||
+ /* Read the information from the port name */
|
||||
+ fd = open (bname, O_RDONLY);
|
||||
+ if (fd < 0)
|
||||
+ grub_util_error (_("cannot open `%s': %s"), bname, strerror (errno));
|
||||
+
|
||||
+ if (read(fd,port_name,sizeof(char)*19) < 0)
|
||||
+ grub_util_error (_("cannot read `%s': %s"), bname, strerror (errno));
|
||||
+
|
||||
+ sscanf(port_name,"0x%s",port_name);
|
||||
+
|
||||
+ close(fd);
|
||||
+
|
||||
+ free(bname);
|
||||
+ free(basepath);
|
||||
+}
|
||||
+
|
||||
static int
|
||||
vendor_is_ATA(const char *path)
|
||||
{
|
||||
@@ -577,6 +608,16 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
|
||||
digit_string = trailing_digits (device);
|
||||
if (strncmp (of_path, "/vdevice/", sizeof ("/vdevice/") - 1) == 0)
|
||||
{
|
||||
+ if(strstr(of_path,"vfc-client"))
|
||||
+ {
|
||||
+ char * port_name = xmalloc(sizeof(char)*17);
|
||||
+ of_fc_port_name(sysfs_path, p, port_name);
|
||||
+
|
||||
+ snprintf(disk,sizeof(disk),"/%s@%s", disk_name, port_name);
|
||||
+ free(port_name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
unsigned long id = 0x8000 | (tgt << 8) | (bus << 5) | lun;
|
||||
if (*digit_string == '\0')
|
||||
{
|
||||
@@ -590,6 +631,13 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
|
||||
snprintf(disk, sizeof (disk),
|
||||
"/%s@%04lx000000000000:%c", disk_name, id, 'a' + (part - 1));
|
||||
}
|
||||
+ }
|
||||
+ } else if (strstr(of_path,"fibre-channel")||(strstr(of_path,"vfc-client"))){
|
||||
+ char * port_name = xmalloc(sizeof(char)*17);
|
||||
+ of_fc_port_name(sysfs_path, p, port_name);
|
||||
+
|
||||
+ snprintf(disk,sizeof(disk),"/%s@%s", disk_name, port_name);
|
||||
+ free(port_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
--
|
||||
2.26.2
|
||||
|
107
0002-ieee1275-powerpc-enables-device-mapper-discovery.patch
Normal file
107
0002-ieee1275-powerpc-enables-device-mapper-discovery.patch
Normal file
@ -0,0 +1,107 @@
|
||||
From 8b31ebfa42eb5af0633191d26fcdcea8c539e521 Mon Sep 17 00:00:00 2001
|
||||
From: Diego Domingos <diegodo@br.ibm.com>
|
||||
Date: Wed, 24 Jun 2020 08:22:50 -0400
|
||||
Subject: [PATCH 2/2] ieee1275/powerpc: enables device mapper discovery
|
||||
|
||||
this patch enables the device mapper discovery on ofpath.c. Currently,
|
||||
when we are dealing with a device like /dev/dm-* the ofpath returns null
|
||||
since there is no function implemented to handle this case.
|
||||
|
||||
This patch implements a function that will look into /sys/block/dm-*
|
||||
devices and search recursively inside slaves directory to find the root
|
||||
disk.
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 64 +++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 63 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index f2bc9fc5c..d1040c4e6 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
+#include <dirent.h>
|
||||
|
||||
#ifdef __sparc__
|
||||
typedef enum
|
||||
@@ -754,13 +755,74 @@ strip_trailing_digits (const char *p)
|
||||
return new;
|
||||
}
|
||||
|
||||
+static char *
|
||||
+get_slave_from_dm(const char * device){
|
||||
+ char *curr_device, *tmp;
|
||||
+ char *directory;
|
||||
+ char *ret = NULL;
|
||||
+
|
||||
+ directory = grub_strdup (device);
|
||||
+ tmp = get_basename(directory);
|
||||
+ curr_device = grub_strdup (tmp);
|
||||
+ *tmp = '\0';
|
||||
+
|
||||
+ /* Recursively check for slaves devices so we can find the root device */
|
||||
+ while ((curr_device[0] == 'd') && (curr_device[1] == 'm') && (curr_device[2] == '-')){
|
||||
+ DIR *dp;
|
||||
+ struct dirent *ep;
|
||||
+ char* device_path;
|
||||
+
|
||||
+ device_path = grub_xasprintf ("/sys/block/%s/slaves", curr_device);
|
||||
+ dp = opendir(device_path);
|
||||
+ free(device_path);
|
||||
+
|
||||
+ if (dp != NULL)
|
||||
+ {
|
||||
+ ep = readdir (dp);
|
||||
+ while (ep != NULL){
|
||||
+
|
||||
+ /* avoid some system directories */
|
||||
+ if (!strcmp(ep->d_name,"."))
|
||||
+ goto next_dir;
|
||||
+ if (!strcmp(ep->d_name,".."))
|
||||
+ goto next_dir;
|
||||
+
|
||||
+ free (curr_device);
|
||||
+ free (ret);
|
||||
+ curr_device = grub_strdup (ep->d_name);
|
||||
+ ret = grub_xasprintf ("%s%s", directory, curr_device);
|
||||
+ break;
|
||||
+
|
||||
+ next_dir:
|
||||
+ ep = readdir (dp);
|
||||
+ continue;
|
||||
+ }
|
||||
+ closedir (dp);
|
||||
+ }
|
||||
+ else
|
||||
+ grub_util_warn (_("cannot open directory `%s'"), device_path);
|
||||
+ }
|
||||
+
|
||||
+ free (directory);
|
||||
+ free (curr_device);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
char *
|
||||
grub_util_devname_to_ofpath (const char *sys_devname)
|
||||
{
|
||||
- char *name_buf, *device, *devnode, *devicenode, *ofpath;
|
||||
+ char *name_buf, *device, *devnode, *devicenode, *ofpath, *realname;
|
||||
|
||||
name_buf = xrealpath (sys_devname);
|
||||
|
||||
+ realname = get_slave_from_dm (name_buf);
|
||||
+ if (realname)
|
||||
+ {
|
||||
+ free (name_buf);
|
||||
+ name_buf = realname;
|
||||
+ }
|
||||
+
|
||||
device = get_basename (name_buf);
|
||||
devnode = strip_trailing_digits (name_buf);
|
||||
devicenode = strip_trailing_digits (device);
|
||||
--
|
||||
2.26.2
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Aug 21 04:40:48 UTC 2020 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Add fibre channel device's ofpath support to grub-ofpathname and search hint
|
||||
to speed up root device discovery (bsc#1172745)
|
||||
* 0001-ieee1275-powerpc-implements-fibre-channel-discovery-.patch
|
||||
* 0002-ieee1275-powerpc-enables-device-mapper-discovery.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 18 06:02:21 UTC 2020 - Michael Chang <mchang@suse.com>
|
||||
|
||||
|
@ -325,6 +325,10 @@ Patch714: 0001-kern-mm.c-Make-grub_calloc-inline.patch
|
||||
# without shim protocol
|
||||
Patch715: 0001-linuxefi-fail-kernel-validation-without-shim-protoco.patch
|
||||
Patch716: 0002-cmdline-Provide-cmdline-functions-as-module.patch
|
||||
# bsc#1172745 L3: SLES 12 SP4 - Slow boot of system after updated kernel -
|
||||
# takes 45 minutes after grub to start loading kernel
|
||||
Patch717: 0001-ieee1275-powerpc-implements-fibre-channel-discovery-.patch
|
||||
Patch718: 0002-ieee1275-powerpc-enables-device-mapper-discovery.patch
|
||||
|
||||
Requires: gettext-runtime
|
||||
%if 0%{?suse_version} >= 1140
|
||||
@ -643,6 +647,8 @@ swap partition while in resuming
|
||||
%patch714 -p1
|
||||
%patch715 -p1
|
||||
%patch716 -p1
|
||||
%patch717 -p1
|
||||
%patch718 -p1
|
||||
|
||||
%build
|
||||
# collect evidence to debug spurious build failure on SLE15
|
||||
|
Loading…
Reference in New Issue
Block a user