File 0599-iscsiroot-try-targets-only-once.patch of Package dracut.12460

From 1fd34ae26591701e27577e381dc284248e3bf6e2 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 4 Apr 2019 16:16:40 +0200
Subject: [PATCH 5/6] iscsiroot: try targets only once

In multipath scenarios, "iscsiadm -m node" may contain
several records with the same target.
There's no point in trying "iscsiadm --login" multiple
time for the same target, through the same portal.

Moreover, warn if the desired target is not on the node
list.
---
 modules.d/95iscsi/iscsiroot.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: dracut-044/modules.d/95iscsi/iscsiroot.sh
===================================================================
--- dracut-044.orig/modules.d/95iscsi/iscsiroot.sh
+++ dracut-044/modules.d/95iscsi/iscsiroot.sh
@@ -97,7 +97,7 @@ handle_netroot()
     local iscsi_in_username iscsi_in_password
     local iscsi_iface_name iscsi_netdev_name
     local iscsi_param param
-    local p
+    local p found
 
     # override conf settings by command line options
     arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=)
@@ -221,6 +221,7 @@ handle_netroot()
         [ -z "$targets" ] && echo "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && exit 1
     fi
 
+    found=
     for target in $targets; do
         if [ "$target" = "$iscsi_target_name" ]; then
             if [ -n "$iscsi_iface_name" ]; then
openSUSE Build Service is sponsored by