]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
iscsi: handle timeout case better
authorHarald Hoyer <harald@redhat.com>
Tue, 18 Aug 2015 09:50:15 +0000 (11:50 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 18 Aug 2015 09:55:05 +0000 (11:55 +0200)
modules.d/95iscsi/iscsiroot.sh
modules.d/95iscsi/parse-iscsiroot.sh

index 2ac9ed325d4eb64111be4cb9b24cf83abd42d343..b7370f6f1819622b5388f2312f05ddb17dea0cd9 100755 (executable)
@@ -108,7 +108,7 @@ handle_netroot()
     parse_iscsi_root "$1" || return 1
 
     # Bail out early, if there is no route to the destination
-    if is_ip "$iscsi_target_ip" && [ "$netif" != "dummy" ] && ! all_ifaces_up && getargbool 1 rd.iscsi.testroute; then
+    if is_ip "$iscsi_target_ip" && [ "$netif" != "timeout" ] && ! all_ifaces_up && getargbool 1 rd.iscsi.testroute; then
         ip route get "$iscsi_target_ip" >/dev/null 2>&1 || return 0
     fi
 
@@ -226,11 +226,11 @@ handle_netroot()
 
 ret=0
 
-if [ "$netif" != "dummy" ] && getargbool 1 rd.iscsi.waitnet; then
+if [ "$netif" != "timeout" ] && getargbool 1 rd.iscsi.waitnet; then
     all_ifaces_up || exit 0
 fi
 
-if [ "$netif" = "dummy" ] && all_ifaces_up; then
+if [ "$netif" = "timeout" ] && all_ifaces_up; then
     # s.th. went wrong and the timeout script hits
     # restart
     systemctl restart iscsid
index 2939e58a622577d7b352a5a0a8f0a3b2830dfcf9..91cd46304ebb27bc83405cc7f6580ed1623f3ce3 100755 (executable)
@@ -42,7 +42,11 @@ if [ "${root%%:*}" = "iscsi" ] ; then
 fi
 
 # If it's not empty or iscsi we don't continue
-[ -z "$netroot" ] || [ "${netroot%%:*}" = "iscsi" ] || return
+for nroot in $(getargs netroot); do
+    [ "${nroot%%:*}" = "iscsi" ] || continue
+    netroot="$nroot"
+    break
+done
 
 if [ -n "$iscsiroot" ] ; then
     [ -z "$netroot" ]  && netroot=$root
@@ -64,12 +68,16 @@ if [ -n "$iscsi_firmware" ] || getargbool 0 rd.iscsi.ibft -d "ip=ibft"; then
     [ -z "$netroot" ] && netroot=iscsi:
     modprobe -b -q iscsi_boot_sysfs 2>/dev/null
     modprobe -b -q iscsi_ibft
+    # if no ip= is given, but firmware
+    echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh
+    initqueue --unique --onetime --timeout /sbin/iscsiroot timeout "$netroot" "$NEWROOT"
+    initqueue --unique --onetime --settled /sbin/iscsiroot dummy "'$netroot'" "'$NEWROOT'"
 fi
 
-initqueue --onetime --timeout /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
 
-# If it's not iscsi we don't continue
-[ "${netroot%%:*}" = "iscsi" ] || return
+[ -z "$netroot" ] || [ "${netroot%%:*}" = "iscsi" ] || return 1
+
+initqueue --unique --onetime --timeout /sbin/iscsiroot timeout "$netroot" "$NEWROOT"
 
 modprobe -q qla4xxx
 modprobe -q cxgb3i
@@ -77,11 +85,6 @@ modprobe -q cxgb4i
 modprobe -q bnx2i
 modprobe -q be2iscsi
 
-if [ -z "$iscsi_firmware" ] ; then
-    type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
-    parse_iscsi_root "$netroot" || return
-fi
-
 # ISCSI actually supported?
 if ! [ -e /sys/module/iscsi_tcp ]; then
     modprobe -q iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi"
@@ -89,7 +92,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 --unique --onetime --settled /sbin/iscsiroot dummy "'$netroot'" "'$NEWROOT'"
     fi
 fi
 
@@ -110,17 +113,21 @@ if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ]
     rm -f /etc/iscsi/initiatorname.iscsi
     mkdir -p /etc/iscsi
     ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
-    systemctl restart iscsid
-    sleep 1
     > /tmp/iscsi_set_initiator
+    if systemctl --quiet is-active iscsid.service; then
+        systemctl restart iscsid
+        sleep 1
+    fi
 fi
 
-if [ -n "$iscsi_firmware" ] ; then
-    echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh
-else
-    netroot_enc=$(str_replace "$netroot" '/' '\2f')
+
+for nroot in $(getargs netroot); do
+    [ "${nroot%%:*}" = "iscsi" ] || continue
+    type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
+    parse_iscsi_root "$nroot" || return 1
+    netroot_enc=$(str_replace "$nroot" '/' '\2f')
     echo "[ -f '/tmp/iscsistarted-$netroot_enc' ]" > $hookdir/initqueue/finished/iscsi_started.sh
-fi
+done
 
 # Done, all good!
 rootok=1