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