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