Blame SOURCES/0301-iscsi-handle-timeout-case-better.patch

18971c
From bfe65f913a4bc6bc5fdb7aa75234c229a2ceef8f Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Tue, 18 Aug 2015 11:50:15 +0200
18971c
Subject: [PATCH] iscsi: handle timeout case better
18971c
18971c
---
18971c
 modules.d/95iscsi/iscsiroot.sh       |  6 ++--
18971c
 modules.d/95iscsi/parse-iscsiroot.sh | 41 ++++++++++++++++------------
18971c
 2 files changed, 27 insertions(+), 20 deletions(-)
18971c
18971c
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
18971c
index 2ac9ed32..b7370f6f 100755
18971c
--- a/modules.d/95iscsi/iscsiroot.sh
18971c
+++ b/modules.d/95iscsi/iscsiroot.sh
18971c
@@ -108,7 +108,7 @@ handle_netroot()
18971c
     parse_iscsi_root "$1" || return 1
18971c
 
18971c
     # Bail out early, if there is no route to the destination
18971c
-    if is_ip "$iscsi_target_ip" && [ "$netif" != "dummy" ] && ! all_ifaces_up && getargbool 1 rd.iscsi.testroute; then
18971c
+    if is_ip "$iscsi_target_ip" && [ "$netif" != "timeout" ] && ! all_ifaces_up && getargbool 1 rd.iscsi.testroute; then
18971c
         ip route get "$iscsi_target_ip" >/dev/null 2>&1 || return 0
18971c
     fi
18971c
 
18971c
@@ -226,11 +226,11 @@ handle_netroot()
18971c
 
18971c
 ret=0
18971c
 
18971c
-if [ "$netif" != "dummy" ] && getargbool 1 rd.iscsi.waitnet; then
18971c
+if [ "$netif" != "timeout" ] && getargbool 1 rd.iscsi.waitnet; then
18971c
     all_ifaces_up || exit 0
18971c
 fi
18971c
 
18971c
-if [ "$netif" = "dummy" ] && all_ifaces_up; then
18971c
+if [ "$netif" = "timeout" ] && all_ifaces_up; then
18971c
     # s.th. went wrong and the timeout script hits
18971c
     # restart
18971c
     systemctl restart iscsid
18971c
diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh
18971c
index 2939e58a..91cd4630 100755
18971c
--- a/modules.d/95iscsi/parse-iscsiroot.sh
18971c
+++ b/modules.d/95iscsi/parse-iscsiroot.sh
18971c
@@ -42,7 +42,11 @@ if [ "${root%%:*}" = "iscsi" ] ; then
18971c
 fi
18971c
 
18971c
 # If it's not empty or iscsi we don't continue
18971c
-[ -z "$netroot" ] || [ "${netroot%%:*}" = "iscsi" ] || return
18971c
+for nroot in $(getargs netroot); do
18971c
+    [ "${nroot%%:*}" = "iscsi" ] || continue
18971c
+    netroot="$nroot"
18971c
+    break
18971c
+done
18971c
 
18971c
 if [ -n "$iscsiroot" ] ; then
18971c
     [ -z "$netroot" ]  && netroot=$root
18971c
@@ -64,12 +68,16 @@ if [ -n "$iscsi_firmware" ] || getargbool 0 rd.iscsi.ibft -d "ip=ibft"; then
18971c
     [ -z "$netroot" ] && netroot=iscsi:
18971c
     modprobe -b -q iscsi_boot_sysfs 2>/dev/null
18971c
     modprobe -b -q iscsi_ibft
18971c
+    # if no ip= is given, but firmware
18971c
+    echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh
18971c
+    initqueue --unique --onetime --timeout /sbin/iscsiroot timeout "$netroot" "$NEWROOT"
18971c
+    initqueue --unique --onetime --settled /sbin/iscsiroot dummy "'$netroot'" "'$NEWROOT'"
18971c
 fi
18971c
 
18971c
-initqueue --onetime --timeout /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
18971c
 
18971c
-# If it's not iscsi we don't continue
18971c
-[ "${netroot%%:*}" = "iscsi" ] || return
18971c
+[ -z "$netroot" ] || [ "${netroot%%:*}" = "iscsi" ] || return 1
18971c
+
18971c
+initqueue --unique --onetime --timeout /sbin/iscsiroot timeout "$netroot" "$NEWROOT"
18971c
 
18971c
 modprobe -q qla4xxx
18971c
 modprobe -q cxgb3i
18971c
@@ -77,11 +85,6 @@ modprobe -q cxgb4i
18971c
 modprobe -q bnx2i
18971c
 modprobe -q be2iscsi
18971c
 
18971c
-if [ -z "$iscsi_firmware" ] ; then
18971c
-    type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
18971c
-    parse_iscsi_root "$netroot" || return
18971c
-fi
18971c
-
18971c
 # ISCSI actually supported?
18971c
 if ! [ -e /sys/module/iscsi_tcp ]; then
18971c
     modprobe -q iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi"
18971c
@@ -89,7 +92,7 @@ fi
18971c
 
18971c
 if [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then
18971c
     if ! getargbool 1 rd.neednet >/dev/null || ! getarg "ip="; then
18971c
-        initqueue --onetime --settled /sbin/iscsiroot dummy "'$netroot'" "'$NEWROOT'"
18971c
+        initqueue --unique --onetime --settled /sbin/iscsiroot dummy "'$netroot'" "'$NEWROOT'"
18971c
     fi
18971c
 fi
18971c
 
18971c
@@ -110,17 +113,21 @@ if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ]
18971c
     rm -f /etc/iscsi/initiatorname.iscsi
18971c
     mkdir -p /etc/iscsi
18971c
     ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
18971c
-    systemctl restart iscsid
18971c
-    sleep 1
18971c
     > /tmp/iscsi_set_initiator
18971c
+    if systemctl --quiet is-active iscsid.service; then
18971c
+        systemctl restart iscsid
18971c
+        sleep 1
18971c
+    fi
18971c
 fi
18971c
 
18971c
-if [ -n "$iscsi_firmware" ] ; then
18971c
-    echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh
18971c
-else
18971c
-    netroot_enc=$(str_replace "$netroot" '/' '\2f')
18971c
+
18971c
+for nroot in $(getargs netroot); do
18971c
+    [ "${nroot%%:*}" = "iscsi" ] || continue
18971c
+    type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
18971c
+    parse_iscsi_root "$nroot" || return 1
18971c
+    netroot_enc=$(str_replace "$nroot" '/' '\2f')
18971c
     echo "[ -f '/tmp/iscsistarted-$netroot_enc' ]" > $hookdir/initqueue/finished/iscsi_started.sh
18971c
-fi
18971c
+done
18971c
 
18971c
 # Done, all good!
18971c
 rootok=1