|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Diego Domingos <diegodo@br.ibm.com>
|
|
|
8e15ce |
Date: Wed, 10 Mar 2021 14:17:52 -0500
|
|
|
8e15ce |
Subject: [PATCH] ieee1275/ofdisk: retry on open failure
|
|
|
8e15ce |
|
|
|
8e15ce |
This patch aims to make grub more robust when booting from SAN/Multipath disks.
|
|
|
8e15ce |
|
|
|
8e15ce |
If a path is failing intermittently so grub will retry the OPEN and READ the
|
|
|
8e15ce |
disk (grub_ieee1275_open and grub_ieee1275_read) until the total amount of times
|
|
|
8e15ce |
specified in MAX_RETRIES.
|
|
|
8e15ce |
|
|
|
8e15ce |
Signed-off-by: Diego Domingos <diegodo@br.ibm.com>
|
|
|
8e15ce |
---
|
|
|
8e15ce |
grub-core/disk/ieee1275/ofdisk.c | 25 ++++++++++++++++++++-----
|
|
|
8e15ce |
include/grub/ieee1275/ofdisk.h | 8 ++++++++
|
|
|
8e15ce |
2 files changed, 28 insertions(+), 5 deletions(-)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
|
|
|
b35c50 |
index ea7f78ac7d..55346849d3 100644
|
|
|
8e15ce |
--- a/grub-core/disk/ieee1275/ofdisk.c
|
|
|
8e15ce |
+++ b/grub-core/disk/ieee1275/ofdisk.c
|
|
|
8e15ce |
@@ -225,7 +225,9 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
|
|
|
8e15ce |
char *buf, *bufptr;
|
|
|
8e15ce |
unsigned i;
|
|
|
8e15ce |
|
|
|
8e15ce |
- if (grub_ieee1275_open (alias->path, &ihandle))
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ RETRY_IEEE1275_OFDISK_OPEN(alias->path, &ihandle)
|
|
|
8e15ce |
+ if (! ihandle)
|
|
|
8e15ce |
return;
|
|
|
8e15ce |
|
|
|
8e15ce |
/* This method doesn't need memory allocation for the table. Open
|
|
|
8e15ce |
@@ -305,7 +307,9 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
|
|
|
8e15ce |
return;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
- if (grub_ieee1275_open (alias->path, &ihandle))
|
|
|
8e15ce |
+ RETRY_IEEE1275_OFDISK_OPEN(alias->path, &ihandle);
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+ if (! ihandle)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
grub_free (buf);
|
|
|
8e15ce |
grub_free (table);
|
|
|
8e15ce |
@@ -495,7 +499,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|
|
8e15ce |
last_ihandle = 0;
|
|
|
8e15ce |
last_devpath = NULL;
|
|
|
8e15ce |
|
|
|
8e15ce |
- grub_ieee1275_open (op->open_path, &last_ihandle);
|
|
|
8e15ce |
+ RETRY_IEEE1275_OFDISK_OPEN(op->open_path, &last_ihandle);
|
|
|
8e15ce |
if (! last_ihandle)
|
|
|
8e15ce |
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
|
|
8e15ce |
last_devpath = op->open_path;
|
|
|
8e15ce |
@@ -571,7 +575,7 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector)
|
|
|
8e15ce |
last_ihandle = 0;
|
|
|
8e15ce |
last_devpath = NULL;
|
|
|
8e15ce |
|
|
|
8e15ce |
- grub_ieee1275_open (disk->data, &last_ihandle);
|
|
|
8e15ce |
+ RETRY_IEEE1275_OFDISK_OPEN(disk->data, &last_ihandle);
|
|
|
8e15ce |
if (! last_ihandle)
|
|
|
8e15ce |
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
|
|
8e15ce |
last_devpath = disk->data;
|
|
|
8e15ce |
@@ -598,12 +602,23 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|
|
8e15ce |
return err;
|
|
|
8e15ce |
grub_ieee1275_read (last_ihandle, buf, size << disk->log_sector_size,
|
|
|
8e15ce |
&actual);
|
|
|
8e15ce |
- if (actual != (grub_ssize_t) (size << disk->log_sector_size))
|
|
|
8e15ce |
+ int i = 0;
|
|
|
8e15ce |
+ while(actual != (grub_ssize_t) (size << disk->log_sector_size)){
|
|
|
8e15ce |
+ if (i>MAX_RETRIES){
|
|
|
8e15ce |
return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
|
|
|
8e15ce |
"from `%s'"),
|
|
|
8e15ce |
(unsigned long long) sector,
|
|
|
8e15ce |
disk->name);
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
+ last_devpath = NULL;
|
|
|
8e15ce |
+ err = grub_ofdisk_prepare (disk, sector);
|
|
|
8e15ce |
+ if (err)
|
|
|
8e15ce |
+ return err;
|
|
|
8e15ce |
|
|
|
8e15ce |
+ grub_ieee1275_read (last_ihandle, buf, size << disk->log_sector_size,
|
|
|
8e15ce |
+ &actual);
|
|
|
8e15ce |
+ i++;
|
|
|
8e15ce |
+ }
|
|
|
8e15ce |
return 0;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h
|
|
|
b35c50 |
index 2f69e3f191..7d2d540930 100644
|
|
|
8e15ce |
--- a/include/grub/ieee1275/ofdisk.h
|
|
|
8e15ce |
+++ b/include/grub/ieee1275/ofdisk.h
|
|
|
8e15ce |
@@ -22,4 +22,12 @@
|
|
|
8e15ce |
extern void grub_ofdisk_init (void);
|
|
|
8e15ce |
extern void grub_ofdisk_fini (void);
|
|
|
8e15ce |
|
|
|
8e15ce |
+#define MAX_RETRIES 20
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+#define RETRY_IEEE1275_OFDISK_OPEN(device, last_ihandle) unsigned retry_i=0;for(retry_i=0; retry_i < MAX_RETRIES; retry_i++){ \
|
|
|
8e15ce |
+ if(!grub_ieee1275_open(device, last_ihandle)) \
|
|
|
8e15ce |
+ break; \
|
|
|
8e15ce |
+ grub_dprintf("ofdisk","Opening disk %s failed. Retrying...\n",device); }
|
|
|
8e15ce |
+
|
|
|
8e15ce |
#endif /* ! GRUB_INIT_HEADER */
|