Blame 0114-iscsi-handle-timeout-case-better.patch

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