nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0505-make-ofdisk_retries-optional.patch

b9d01e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b9d01e
From: Diego Domingos <diegdo@br.ibm.com>
b9d01e
Date: Thu, 24 Mar 2022 13:14:42 -0400
b9d01e
Subject: [PATCH] make ofdisk_retries optional
b9d01e
b9d01e
The feature Retry on Fail added to GRUB can cause a LPM to take
b9d01e
longer if the SAN is slow.
b9d01e
b9d01e
When a LPM to external site occur, the path of the disk can change
b9d01e
and thus the disk search function on grub can take some time since
b9d01e
it is used as a hint. This can cause the Retry on Fail feature to
b9d01e
try to access the disk 20x times (since this is hardcoded number)
b9d01e
and, if the SAN is slow, the boot time can increase a lot.
b9d01e
In some situations not acceptable.
b9d01e
b9d01e
The following patch enables a configuration at user space of the
b9d01e
maximum number of retries we want for this feature.
b9d01e
b9d01e
The variable ofdisk_retries should be set using grub2-editenv
b9d01e
and will be checked by retry function. If the variable is not set,
b9d01e
so the default number of retries will be used instead.
b9d01e
---
b9d01e
 include/grub/ieee1275/ofdisk.h | 7 ++++++-
b9d01e
 1 file changed, 6 insertions(+), 1 deletion(-)
b9d01e
b9d01e
diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h
b9d01e
index 7d2d540930..0074d55eee 100644
b9d01e
--- a/include/grub/ieee1275/ofdisk.h
b9d01e
+++ b/include/grub/ieee1275/ofdisk.h
b9d01e
@@ -25,7 +25,12 @@ extern void grub_ofdisk_fini (void);
b9d01e
 #define MAX_RETRIES 20
b9d01e
 
b9d01e
 
b9d01e
-#define RETRY_IEEE1275_OFDISK_OPEN(device, last_ihandle) unsigned retry_i=0;for(retry_i=0; retry_i < MAX_RETRIES; retry_i++){ \
b9d01e
+#define RETRY_IEEE1275_OFDISK_OPEN(device, last_ihandle) \
b9d01e
+	                                        unsigned max_retries = MAX_RETRIES; \
b9d01e
+                                                if(grub_env_get("ofdisk_retries") != NULL) \
b9d01e
+                                                     max_retries = grub_strtoul(grub_env_get("ofdisk_retries"), 0, 10)+1; \
b9d01e
+                                                grub_dprintf("ofdisk","MAX_RETRIES set to %u\n",max_retries); \
b9d01e
+                                                unsigned retry_i=0;for(retry_i=0; retry_i < max_retries; retry_i++){ \
b9d01e
 						if(!grub_ieee1275_open(device, last_ihandle)) \
b9d01e
 						break; \
b9d01e
 						grub_dprintf("ofdisk","Opening disk %s failed. Retrying...\n",device); }