3888c9
From 7e148e3b6f922e5eb1dcb7fc3c1fed715004e2ab Mon Sep 17 00:00:00 2001
3888c9
From: Lee Duncan <lduncan@suse.com>
3888c9
Date: Mon, 25 Mar 2019 16:49:19 -0700
3888c9
Subject: [PATCH] Dracut: only login to one target at a time
3888c9
3888c9
For handling the configuration where there are two
3888c9
paths to an iscsi root target, each using a different
3888c9
NIC. In such a case, the initramfs was trying to configure
3888c9
the first NIC, then call iscsiroot to login to both targets,
3888c9
which would fail for the 2nd target, since the path to the
3888c9
2nd target was not yet configured. This would eventually
3888c9
work after a timeout. But it's better to login to just
3888c9
one target at a time.
3888c9
This change makes the initramfs handle multiple paths to an
3888c9
iscsi target better by logging into only one target at a time,
3888c9
rather than trying to login to all targets when only one of
3888c9
several NICs is up.
3888c9
3888c9
This can be further optimized by using the initrd parameter
3888c9
"rd.iscsi.testroute", which would skip iscsiadm login attempts
3888c9
for targets to which no route exists.
3888c9
3888c9
If the script is called again via the timeout initqueue,
3888c9
we try "iscsiadm -L onboot" again, hoping that some targets
3888c9
may now have become reachable.
3888c9
---
3888c9
 modules.d/95iscsi/iscsiroot.sh | 12 +++++++++---
3888c9
 1 file changed, 9 insertions(+), 3 deletions(-)
3888c9
3888c9
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
3888c9
index 4efc1d12..f3f88259 100755
3888c9
--- a/modules.d/95iscsi/iscsiroot.sh
3888c9
+++ b/modules.d/95iscsi/iscsiroot.sh
3888c9
@@ -228,7 +228,7 @@ handle_netroot()
3888c9
             fi
3888c9
             [ -n "$iscsi_param" ] && for param in $iscsi_param; do EXTRA="$EXTRA --name=${param%=*} --value=${param#*=}"; done
3888c9
 
3888c9
-            iscsiadm -m node -T $target \
3888c9
+            CMD="iscsiadm -m node -T $target \
3888c9
                      ${iscsi_iface_name:+-I $iscsi_iface_name} \
3888c9
                      -p $iscsi_target_ip${iscsi_target_port:+:$iscsi_target_port} \
3888c9
                      --op=update \
3888c9
@@ -238,14 +238,20 @@ handle_netroot()
3888c9
                      ${iscsi_in_username:+--name=node.session.auth.username_in --value=$iscsi_in_username} \
3888c9
                      ${iscsi_in_password:+--name=node.session.auth.password_in --value=$iscsi_in_password} \
3888c9
                      $EXTRA \
3888c9
-                     $NULL
3888c9
+                     $NULL"
3888c9
+            $CMD
3888c9
+            if [ "$netif" != "timeout" ]; then
3888c9
+                $CMD --login
3888c9
+            fi
3888c9
         ;;
3888c9
         *)
3888c9
         ;;
3888c9
         esac
3888c9
     done
3888c9
 
3888c9
-    iscsiadm -m node -L onboot || :
3888c9
+    if [ "$netif" = "timeout" ]; then
3888c9
+        iscsiadm -m node -L onboot || :
3888c9
+    fi
3888c9
     > $hookdir/initqueue/work
3888c9
 
3888c9
     netroot_enc=$(str_replace "$1" '/' '\2f')
3888c9