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

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