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

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