iSCSI: no more iscsid

According to Cathy Zhou <Cathy.Zhou@Oracle.COM>:

"iscsistart is not designed to be working together with iscsid. When an
interface gets the dhcp offer successfully, the iscsiroot script is run
which starts the iscsistart service to establish the iSCSI session. With
the existence of iscsid, the iscsistart service's attempt to setup its
own mgmt ipc fails. Instead, the request to login to the iscsi target
is handled by the mgmt ipc of iscsid. After iscsistart finishes its
login attempt, it eventually sends a stop_event_loop request to stop
the mgmt process. As the result, it terminates iscsid."

So, iscsid is kicked out again.

Additionally iscsistart-flocked is used to make sure iscsistart is not
run in parallel.
master
Harald Hoyer 2018-01-12 10:24:20 +01:00
parent b7a7ab1943
commit 28a68f1f3c
6 changed files with 44 additions and 61 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh

[ -z "${DRACUT_SYSTEMD}" ] && [ -e /sys/module/bnx2i ] && killproc iscsiuio
[ -e /sys/module/bnx2i ] && killproc iscsiuio


View File

@ -36,14 +36,14 @@ iroot=${iroot#:}
# figured out a way how to check whether this is built-in or not
modprobe crc32c 2>/dev/null

if [ -z "${DRACUT_SYSTEMD}" ] && [ -e /sys/module/bnx2i ] && ! [ -e /tmp/iscsiuio-started ]; then
if [ -e /sys/module/bnx2i ] && ! [ -e /tmp/iscsiuio-started ]; then
iscsiuio
> /tmp/iscsiuio-started
fi

handle_firmware()
{
if ! iscsistart -f; then
if ! iscsistart-flocked -f; then
warn "iscistart: Could not get list of targets from firmware. Skipping."
echo 'skipped' > "/tmp/iscsistarted-firmware"
return 0
@ -53,7 +53,7 @@ handle_firmware()
iscsi_param="$iscsi_param --param $p"
done

if ! iscsistart -b $iscsi_param; then
if ! iscsistart-flocked -b $iscsi_param; then
warn "'iscsistart -b $iscsi_param' failed with return code $?"
fi

@ -117,11 +117,6 @@ handle_netroot()
mkdir -p /etc/iscsi
ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
> /tmp/iscsi_set_initiator
if [ -n "$DRACUT_SYSTEMD" ]; then
systemctl try-restart iscsid
# FIXME: iscsid is not yet ready, when the service is :-/
sleep 1
fi
fi

if [ -z "$iscsi_initiator" ]; then
@ -138,11 +133,6 @@ handle_netroot()
mkdir -p /etc/iscsi
ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
> /tmp/iscsi_set_initiator
if [ -n "$DRACUT_SYSTEMD" ]; then
systemctl try-restart iscsid
# FIXME: iscsid is not yet ready, when the service is :-/
sleep 1
fi
fi


@ -163,11 +153,6 @@ handle_netroot()
if ! [ -e /etc/iscsi/initiatorname.iscsi ]; then
mkdir -p /etc/iscsi
ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
if [ -n "$DRACUT_SYSTEMD" ]; then
systemctl try-restart iscsid
# FIXME: iscsid is not yet ready, when the service is :-/
sleep 1
fi
fi
# FIXME $iscsi_protocol??

@ -193,7 +178,7 @@ handle_netroot()
--description="Login iSCSI Target $iscsi_target_name" \
-p 'DefaultDependencies=no' \
--unit="$netroot_enc" -- \
$(command -v iscsistart) \
$(command -v iscsistart-flocked) \
-i "$iscsi_initiator" -t "$iscsi_target_name" \
-g "$iscsi_target_group" -a "$iscsi_target_ip" \
-p "$iscsi_target_port" \
@ -211,7 +196,7 @@ handle_netroot()
fi
fi
else
iscsistart -i "$iscsi_initiator" -t "$iscsi_target_name" \
iscsistart-flocked -i "$iscsi_initiator" -t "$iscsi_target_name" \
-g "$iscsi_target_group" -a "$iscsi_target_ip" \
-p "$iscsi_target_port" \
${iscsi_username:+-u "$iscsi_username"} \

View File

@ -0,0 +1,5 @@
#!/bin/sh
{
flock -e 9
iscsistart "$@"
} 9>/tmp/.iscsi_lock

View File

@ -194,41 +194,12 @@ install() {
[[ $_iscsiconf ]] && printf "%s\n" "$_iscsiconf" >> "${initdir}/etc/cmdline.d/95iscsi.conf"
fi

inst "$moddir/iscsistart-flocked.sh" "/bin/iscsistart-flocked"
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
if ! dracut_module_included "systemd"; then
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
else
inst_multiple -o \
$systemdsystemunitdir/iscsi.service \
$systemdsystemunitdir/iscsid.service \
$systemdsystemunitdir/iscsid.socket \
$systemdsystemunitdir/iscsiuio.service \
$systemdsystemunitdir/iscsiuio.socket \
iscsiadm iscsid

mkdir -p "${initdir}/$systemdsystemunitdir/sockets.target.wants"
for i in \
iscsiuio.socket \
; do
ln_r "$systemdsystemunitdir/${i}" "$systemdsystemunitdir/sockets.target.wants/${i}"
done

mkdir -p "${initdir}/$systemdsystemunitdir/basic.target.wants"
for i in \
iscsid.service \
; do
ln_r "$systemdsystemunitdir/${i}" "$systemdsystemunitdir/basic.target.wants/${i}"
done

# Make sure iscsid is started after dracut-cmdline and ready for the initqueue
mkdir -p "${initdir}/$systemdsystemunitdir/iscsid.service.d"
(
echo "[Unit]"
echo "After=dracut-cmdline.service"
echo "Before=dracut-initqueue.service"
) > "${initdir}/$systemdsystemunitdir/iscsid.service.d/dracut.conf"
fi
inst_dir /var/lib/iscsi
dracut_need_initqueue

View File

@ -116,11 +116,6 @@ if arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=) && [ -n "$arg" ] && ! [
if ! [ -e /etc/iscsi/initiatorname.iscsi ]; then
mkdir -p /etc/iscsi
ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
if [ -n "$DRACUT_SYSTEMD" ]; then
systemctl try-restart iscsid
# FIXME: iscsid is not yet ready, when the service is :-/
sleep 1
fi
fi
fi

@ -133,11 +128,6 @@ if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ]
mkdir -p /etc/iscsi
ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
> /tmp/iscsi_set_initiator
if [ -n "$DRACUT_SYSTEMD" ]; then
systemctl try-restart iscsid
# FIXME: iscsid is not yet ready, when the service is :-/
sleep 1
fi
fi
fi


View File

@ -73,6 +73,38 @@ do_test_run() {
"rd.iscsi.initiator=$initiator" \
|| return 1

run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0" \
"root=LABEL=sysroot" \
"ip=192.168.50.101:::255.255.255.0::ens3:off" \
"ip=192.168.51.101:::255.255.255.0::ens4:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.firmware" \
"rd.iscsi.initiator=$initiator" \
"rd.iscsi.waitnet=0" \
|| return 1

run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
"root=LABEL=sysroot" \
"ip=192.168.50.101:::255.255.255.0::ens3:off" \
"ip=192.168.51.101:::255.255.255.0::ens4:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.firmware" \
"rd.iscsi.initiator=$initiator" \
"rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
|| return 1

run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0 default GW" \
"root=LABEL=sysroot" \
"ip=192.168.50.101::192.168.50.1:255.255.255.0::ens3:off" \
"ip=192.168.51.101::192.168.51.1:255.255.255.0::ens4:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.firmware" \
"rd.iscsi.initiator=$initiator" \
"rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
|| return 1

echo "All tests passed [OK]"
return 0