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