From bfe65f913a4bc6bc5fdb7aa75234c229a2ceef8f Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 18 Aug 2015 11:50:15 +0200 Subject: [PATCH] iscsi: handle timeout case better --- modules.d/95iscsi/iscsiroot.sh | 6 +++--- modules.d/95iscsi/parse-iscsiroot.sh | 41 +++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh index 2ac9ed32..b7370f6f 100755 --- a/modules.d/95iscsi/iscsiroot.sh +++ b/modules.d/95iscsi/iscsiroot.sh @@ -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 diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh index 2939e58a..91cd4630 100755 --- a/modules.d/95iscsi/parse-iscsiroot.sh +++ b/modules.d/95iscsi/parse-iscsiroot.sh @@ -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