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