Blame SOURCES/0085-iscsi-more-iscsiroot-fixes.patch

a56a5e
From 6c7c8d8a071694efd0c7e450fa78e71224a8ced4 Mon Sep 17 00:00:00 2001
966cef
From: Harald Hoyer <harald@redhat.com>
966cef
Date: Wed, 22 Jan 2014 17:05:22 +0100
966cef
Subject: [PATCH] iscsi: more iscsiroot fixes
966cef
966cef
handle iscsiroot with firmware more gracefully
966cef
---
966cef
 modules.d/95iscsi/iscsiroot.sh       | 68 +++++++++++++++++++++++++-----------
966cef
 modules.d/95iscsi/parse-iscsiroot.sh |  6 ++--
966cef
 2 files changed, 50 insertions(+), 24 deletions(-)
966cef
966cef
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
966cef
index 156003c..6868710 100755
966cef
--- a/modules.d/95iscsi/iscsiroot.sh
966cef
+++ b/modules.d/95iscsi/iscsiroot.sh
966cef
@@ -31,36 +31,45 @@ iroot="$2"
966cef
 # If it's not iscsi we don't continue
966cef
 [ "${iroot%%:*}" = "iscsi" ] || exit 1
966cef
 
966cef
-iroot=${iroot#iscsi:}
966cef
+iroot=${iroot#iscsi}
966cef
+iroot=${iroot#:}
966cef
 
966cef
 # XXX modprobe crc32c should go in the cmdline parser, but I haven't yet
966cef
 # figured out a way how to check whether this is built-in or not
966cef
 modprobe crc32c 2>/dev/null
966cef
 
966cef
-[ -e /sys/module/bnx2i ] && iscsiuio
966cef
-
966cef
-if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
966cef
-    for p in $(getargs rd.iscsi.param -d iscsi_param); do
966cef
-	iscsi_param="$iscsi_param --param $p"
966cef
-    done
966cef
+if [ -e /sys/module/bnx2i ] && ! [ -e /tmp/iscsiuio-started ]; then
966cef
+        iscsiuio
966cef
+        > /tmp/iscsiuio-started
966cef
+fi
966cef
 
966cef
+handle_firmware()
966cef
+{
966cef
     if ! [ -e /tmp/iscsistarted-firmware ]; then
966cef
-        if ! iscsistart -f | vinfo; then
966cef
+        if ! iscsistart -f; then
966cef
             warn "iscistart: Could not get list of targets from firmware."
966cef
-            exit 1
966cef
+            return 1
966cef
         fi
966cef
 
966cef
-        if ! iscsistart -b $iscsi_param 2>&1 | vinfo; then
966cef
+        for p in $(getargs rd.iscsi.param -d iscsi_param); do
966cef
+	    iscsi_param="$iscsi_param --param $p"
966cef
+        done
966cef
+
966cef
+        if ! iscsistart -b $iscsi_param; then
966cef
             warn "\`iscsistart -b $iscsi_param\ยด failed"
966cef
-            exit 1
966cef
         fi
966cef
-        echo 'started' > "/tmp/iscsistarted-iscsi"
966cef
-        echo 'started' > "/tmp/iscsistarted-firmware"
966cef
+
966cef
+        if [ -d /sys/class/iscsi_session ]; then
966cef
+            echo 'started' > "/tmp/iscsistarted-iscsi"
966cef
+            echo 'started' > "/tmp/iscsistarted-firmware"
966cef
+        else
966cef
+            return 1
966cef
+        fi
966cef
+
966cef
         need_shutdown
966cef
     fi
966cef
-
966cef
-    [ "$netif" = dummy ] && exit 0
966cef
-fi
966cef
+    return 0
966cef
+}
966cef
 
966cef
 
966cef
 handle_netroot()
966cef
@@ -171,21 +180,38 @@ handle_netroot()
966cef
 
966cef
     netroot_enc=$(str_replace "$1" '/' '\2f')
966cef
     echo 'started' > "/tmp/iscsistarted-iscsi:${netroot_enc}"
966cef
-
966cef
 }
966cef
 
966cef
+ret=0
966cef
+
966cef
 # loop over all netroot parameter
966cef
 if getarg netroot; then
966cef
     for nroot in $(getargs netroot); do
966cef
-        [ "${netroot%%:*}" = "iscsi" ] || continue
966cef
-        handle_netroot ${nroot##iscsi:}
966cef
+        [ "${nroot%%:*}" = "iscsi" ] || continue
966cef
+        nroot="${nroot##iscsi:}"
966cef
+        if [ -n "$nroot" ]; then
966cef
+            handle_netroot "$nroot"
966cef
+            ret=$(($ret + $?))
966cef
+        fi
966cef
     done
966cef
+    if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
966cef
+        handle_firmware
966cef
+        ret=$(($ret + $?))
966cef
+    fi
966cef
 else
966cef
-    handle_netroot $iroot
966cef
+    if [ -n "$iroot" ]; then
966cef
+        handle_netroot "$iroot"
966cef
+        ret=$?
966cef
+    else
966cef
+        if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
966cef
+            handle_firmware
966cef
+            ret=$?
966cef
+        fi
966cef
+    fi
966cef
 fi
966cef
 
966cef
 need_shutdown
966cef
 
966cef
 # now we have a root filesystem somewhere in /dev/sda*
966cef
 # let the normal block handler handle root=
966cef
-exit 0
966cef
+exit $ret
966cef
diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh
966cef
index e463add..4be9d56 100755
966cef
--- a/modules.d/95iscsi/parse-iscsiroot.sh
966cef
+++ b/modules.d/95iscsi/parse-iscsiroot.sh
966cef
@@ -61,10 +61,10 @@ fi
966cef
 
966cef
 # iscsi_firmware does not need argument checking
966cef
 if [ -n "$iscsi_firmware" ] ; then
966cef
-    netroot=${netroot:-iscsi}
966cef
+    netroot=${netroot:-iscsi:}
966cef
     modprobe -q iscsi_boot_sysfs 2>/dev/null
966cef
     modprobe -q iscsi_ibft
966cef
-    initqueue --settled /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
966cef
+    initqueue --onetime --timeout "/sbin/iscsiroot dummy '$netroot' '$NEWROOT'"
966cef
 fi
966cef
 
966cef
 # If it's not iscsi we don't continue
966cef
@@ -88,7 +88,7 @@ fi
966cef
 
966cef
 if [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then
966cef
     if ! getargbool 1 rd.neednet >/dev/null || ! getarg "ip="; then
966cef
-        initqueue --onetime --settled /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
966cef
+        initqueue --onetime --settled "/sbin/iscsiroot dummy '$netroot' '$NEWROOT'"
966cef
     fi
966cef
 fi
966cef