]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[block] Add a small delay between attempts to reopen SAN targets
authorMichael Brown <mcb30@ipxe.org>
Mon, 27 Mar 2017 12:32:29 +0000 (15:32 +0300)
committerMichael Brown <mcb30@ipxe.org>
Mon, 27 Mar 2017 12:41:22 +0000 (15:41 +0300)
When all SAN targets are completely unreachable, there will be a
natural delay between reopening attempts due to the network connection
timeout on the unreachable targets.

However, some SAN targets may accept connections instantly and report
a temporary unavailability by e.g. failing the TEST UNIT READY
command.  If all targets are behaving this way then there will be no
natural delay, and we will attempt to saturate the network with
connection attempts.

Fix by introducing a small delay between attempts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/sanboot.c

index c7279ad363c2f52e426f93ee76c9a254f5a4eb53..efab3d02fe81f0649f1a278c29b9168c44de6dfb 100644 (file)
@@ -74,6 +74,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  */
 #define SAN_DEFAULT_RETRIES 10
 
+/**
+ * Delay between reopening attempts
+ *
+ * Some SAN targets will always accept connections instantly and
+ * report a temporary unavailability by e.g. failing the TEST UNIT
+ * READY command.  Avoid bombarding such targets by introducing a
+ * small delay between attempts.
+ */
+#define SAN_REOPEN_DELAY_SECS 5
+
 /** List of SAN devices */
 LIST_HEAD ( san_devices );
 
@@ -484,6 +494,10 @@ sandev_command ( struct san_device *sandev,
                /* Reopen block device if applicable */
                if ( sandev_needs_reopen ( sandev ) &&
                     ( ( rc = sandev_reopen ( sandev ) ) != 0 ) ) {
+
+                       /* Delay reopening attempts */
+                       sleep_fixed ( SAN_REOPEN_DELAY_SECS );
+
                        continue;
                }