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

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