]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
iscsi: more iscsiroot fixes
authorHarald Hoyer <harald@redhat.com>
Wed, 22 Jan 2014 16:05:22 +0000 (17:05 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 22 Jan 2014 16:40:10 +0000 (17:40 +0100)
handle iscsiroot with firmware more gracefully

modules.d/95iscsi/iscsiroot.sh
modules.d/95iscsi/parse-iscsiroot.sh

index 156003c09098a0f5aab1e6ce07e7db083d610ea1..6868710254f993679d7fff40435e54ca5ef90d56 100755 (executable)
@@ -31,36 +31,45 @@ iroot="$2"
 # If it's not iscsi we don't continue
 [ "${iroot%%:*}" = "iscsi" ] || exit 1
 
-iroot=${iroot#iscsi:}
+iroot=${iroot#iscsi}
+iroot=${iroot#:}
 
 # XXX modprobe crc32c should go in the cmdline parser, but I haven't yet
 # figured out a way how to check whether this is built-in or not
 modprobe crc32c 2>/dev/null
 
-[ -e /sys/module/bnx2i ] && iscsiuio
-
-if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
-    for p in $(getargs rd.iscsi.param -d iscsi_param); do
-       iscsi_param="$iscsi_param --param $p"
-    done
+if [ -e /sys/module/bnx2i ] && ! [ -e /tmp/iscsiuio-started ]; then
+        iscsiuio
+        > /tmp/iscsiuio-started
+fi
 
+handle_firmware()
+{
     if ! [ -e /tmp/iscsistarted-firmware ]; then
-        if ! iscsistart -f | vinfo; then
+        if ! iscsistart -f; then
             warn "iscistart: Could not get list of targets from firmware."
-            exit 1
+            return 1
         fi
 
-        if ! iscsistart -b $iscsi_param 2>&1 | vinfo; then
+        for p in $(getargs rd.iscsi.param -d iscsi_param); do
+           iscsi_param="$iscsi_param --param $p"
+        done
+
+        if ! iscsistart -b $iscsi_param; then
             warn "\`iscsistart -b $iscsi_param\ยด failed"
-            exit 1
         fi
-        echo 'started' > "/tmp/iscsistarted-iscsi"
-        echo 'started' > "/tmp/iscsistarted-firmware"
+
+        if [ -d /sys/class/iscsi_session ]; then
+            echo 'started' > "/tmp/iscsistarted-iscsi"
+            echo 'started' > "/tmp/iscsistarted-firmware"
+        else
+            return 1
+        fi
+
         need_shutdown
     fi
-
-    [ "$netif" = dummy ] && exit 0
-fi
+    return 0
+}
 
 
 handle_netroot()
@@ -171,21 +180,38 @@ handle_netroot()
 
     netroot_enc=$(str_replace "$1" '/' '\2f')
     echo 'started' > "/tmp/iscsistarted-iscsi:${netroot_enc}"
-
 }
 
+ret=0
+
 # loop over all netroot parameter
 if getarg netroot; then
     for nroot in $(getargs netroot); do
-        [ "${netroot%%:*}" = "iscsi" ] || continue
-        handle_netroot ${nroot##iscsi:}
+        [ "${nroot%%:*}" = "iscsi" ] || continue
+        nroot="${nroot##iscsi:}"
+        if [ -n "$nroot" ]; then
+            handle_netroot "$nroot"
+            ret=$(($ret + $?))
+        fi
     done
+    if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
+        handle_firmware
+        ret=$(($ret + $?))
+    fi
 else
-    handle_netroot $iroot
+    if [ -n "$iroot" ]; then
+        handle_netroot "$iroot"
+        ret=$?
+    else
+        if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
+            handle_firmware
+            ret=$?
+        fi
+    fi
 fi
 
 need_shutdown
 
 # now we have a root filesystem somewhere in /dev/sda*
 # let the normal block handler handle root=
-exit 0
+exit $ret
index e463addbc53c671881f646e3b26187040b35cd35..4be9d5612131fc45e1d4396e5ed9784273be4235 100755 (executable)
@@ -61,10 +61,10 @@ fi
 
 # iscsi_firmware does not need argument checking
 if [ -n "$iscsi_firmware" ] ; then
-    netroot=${netroot:-iscsi}
+    netroot=${netroot:-iscsi:}
     modprobe -q iscsi_boot_sysfs 2>/dev/null
     modprobe -q iscsi_ibft
-    initqueue --settled /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
+    initqueue --onetime --timeout "/sbin/iscsiroot dummy '$netroot' '$NEWROOT'"
 fi
 
 # If it's not iscsi we don't continue
@@ -88,7 +88,7 @@ fi
 
 if [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then
     if ! getargbool 1 rd.neednet >/dev/null || ! getarg "ip="; then
-        initqueue --onetime --settled /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
+        initqueue --onetime --settled "/sbin/iscsiroot dummy '$netroot' '$NEWROOT'"
     fi
 fi