iscsi: handle timeout case better

Harald Hoyer 2015-08-18 11:50:15 +02:00
parent 415d0c68ab
commit bfe65f913a
2 changed files with 27 additions and 20 deletions

View File

@ -108,7 +108,7 @@ handle_netroot()
parse_iscsi_root "$1" || return 1 parse_iscsi_root "$1" || return 1


# Bail out early, if there is no route to the destination # 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 ip route get "$iscsi_target_ip" >/dev/null 2>&1 || return 0
fi fi


@ -226,11 +226,11 @@ handle_netroot()


ret=0 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 all_ifaces_up || exit 0
fi fi


if [ "$netif" = "dummy" ] && all_ifaces_up; then if [ "$netif" = "timeout" ] && all_ifaces_up; then
# s.th. went wrong and the timeout script hits # s.th. went wrong and the timeout script hits
# restart # restart
systemctl restart iscsid systemctl restart iscsid

View File

@ -42,7 +42,11 @@ if [ "${root%%:*}" = "iscsi" ] ; then
fi fi


# If it's not empty or iscsi we don't continue # 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 if [ -n "$iscsiroot" ] ; then
[ -z "$netroot" ] && netroot=$root [ -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: [ -z "$netroot" ] && netroot=iscsi:
modprobe -b -q iscsi_boot_sysfs 2>/dev/null modprobe -b -q iscsi_boot_sysfs 2>/dev/null
modprobe -b -q iscsi_ibft 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 fi


initqueue --onetime --timeout /sbin/iscsiroot dummy "$netroot" "$NEWROOT"


# If it's not iscsi we don't continue [ -z "$netroot" ] || [ "${netroot%%:*}" = "iscsi" ] || return 1
[ "${netroot%%:*}" = "iscsi" ] || return
initqueue --unique --onetime --timeout /sbin/iscsiroot timeout "$netroot" "$NEWROOT"


modprobe -q qla4xxx modprobe -q qla4xxx
modprobe -q cxgb3i modprobe -q cxgb3i
@ -77,11 +85,6 @@ modprobe -q cxgb4i
modprobe -q bnx2i modprobe -q bnx2i
modprobe -q be2iscsi 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? # ISCSI actually supported?
if ! [ -e /sys/module/iscsi_tcp ]; then if ! [ -e /sys/module/iscsi_tcp ]; then
modprobe -q iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi" 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 [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then
if ! getargbool 1 rd.neednet >/dev/null || ! getarg "ip="; 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
fi fi


@ -110,17 +113,21 @@ if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ]
rm -f /etc/iscsi/initiatorname.iscsi rm -f /etc/iscsi/initiatorname.iscsi
mkdir -p /etc/iscsi mkdir -p /etc/iscsi
ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
> /tmp/iscsi_set_initiator
if systemctl --quiet is-active iscsid.service; then
systemctl restart iscsid systemctl restart iscsid
sleep 1 sleep 1
> /tmp/iscsi_set_initiator fi
fi fi


if [ -n "$iscsi_firmware" ] ; then
echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh for nroot in $(getargs netroot); do
else [ "${nroot%%:*}" = "iscsi" ] || continue
netroot_enc=$(str_replace "$netroot" '/' '\2f') 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 echo "[ -f '/tmp/iscsistarted-$netroot_enc' ]" > $hookdir/initqueue/finished/iscsi_started.sh
fi done


# Done, all good! # Done, all good!
rootok=1 rootok=1