File 0611-Dracut-only-login-to-one-target-at-a-time.patch of Package dracut

From b2909a5386d9e852617e0dc414951e5d60d1f54e Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Mon, 25 Mar 2019 16:49:19 -0700
Subject: [PATCH] Dracut: only login to one target at a time

For handling the configuration where there are two
paths to an iscsi root target, each using a different
NIC. In such a case, the initramfs was trying to configure
the first NIC, then call iscsiroot to login to both targets,
which would fail for the 2nd target, since the path to the
2nd target was not yet configured. This would eventually
work after a timeout. But it's better to login to just
one target at a time.
This change makes the initramfs handle multiple paths to an
iscsi target better by logging into only one target at a time,
rather than trying to login to all targets when only one of
several NICs is up.

This can be further optimized by using the initrd parameter
"rd.iscsi.testroute", which would skip iscsiadm login attempts
for targets to which no route exists.

If the script is called again via the timeout initqueue,
we try "iscsiadm -L onboot" again, hoping that some targets
may now have become reachable.
---
 modules.d/95iscsi/iscsiroot.sh | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
index 3a2463f5..4eb9d491 100755
--- a/modules.d/95iscsi/iscsiroot.sh
+++ b/modules.d/95iscsi/iscsiroot.sh
@@ -232,16 +232,32 @@ handle_netroot()
             else
                 COMMAND="iscsiadm -m node -T $target -p $iscsi_target_ip${iscsi_target_port:+:$iscsi_target_port} --op=update"
             fi
-            $($COMMAND --name=node.startup --value=onboot)
-            [ -n "$iscsi_username" ] && $($COMMAND --name=node.session.auth.username --value=$iscsi_username)
-            [ -n "$iscsi_password" ] && $($COMMAND --name=node.session.auth.password --value=$iscsi_password)
-            [ -n "$iscsi_in_username" ] && $($COMMAND --name=node.session.auth.username_in --value=$iscsi_in_username)
-            [ -n "$iscsi_in_password" ] && $($COMMAND --name=node.session.auth.password_in --value=$iscsi_in_password)
-            [ -n "$iscsi_param" ] && for param in $iscsi_param; do $($COMMAND --name=${param%=*} --value=${param#*=}); done
-        fi
+            [ -n "$iscsi_param" ] && for param in $iscsi_param; do EXTRA="$EXTRA --name=${param%=*} --value=${param#*=}"; done
+
+            CMD="iscsiadm -m node -T $target \
+                     ${iscsi_iface_name:+-I $iscsi_iface_name} \
+                     -p $iscsi_target_ip${iscsi_target_port:+:$iscsi_target_port} \
+                     --op=update \
+                     --name=node.startup --value=onboot \
+                     ${iscsi_username:+   --name=node.session.auth.username    --value=$iscsi_username} \
+                     ${iscsi_password:+   --name=node.session.auth.password    --value=$iscsi_password} \
+                     ${iscsi_in_username:+--name=node.session.auth.username_in --value=$iscsi_in_username} \
+                     ${iscsi_in_password:+--name=node.session.auth.password_in --value=$iscsi_in_password} \
+                     $EXTRA \
+                     $NULL"
+            $CMD
+            if [ "$netif" != "timeout" ]; then
+                $CMD --login
+            fi
+        ;;
+        *)
+        ;;
+        esac
     done
 
-    iscsiadm -m node -L onboot || :
+    if [ "$netif" = "timeout" ]; then
+        iscsiadm -m node -L onboot || :
+    fi
     > $hookdir/initqueue/work
 
     netroot_enc=$(str_replace "$1" '/' '\2f')
-- 
2.16.4

openSUSE Build Service is sponsored by