From 80603fd5378a7ec4e274188bd5582fa94ec69b27 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Mon, 28 Oct 2019 10:20:56 -0700 Subject: [PATCH 1/1] improve systemd service files for boot session handling --- etc/systemd/iscsi-mark-root-nodes | 6 +++++- etc/systemd/iscsi-onboot.service | 15 +++++++++++++++ etc/systemd/iscsi.service | 8 ++------ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 etc/systemd/iscsi-onboot.service diff --git a/etc/systemd/iscsi-mark-root-nodes b/etc/systemd/iscsi-mark-root-nodes index 6bddf6c..cc76100 100644 --- a/etc/systemd/iscsi-mark-root-nodes +++ b/etc/systemd/iscsi-mark-root-nodes @@ -9,7 +9,11 @@ while read t num p target flash; do portal=${p%,*} transport=${t%:} - $ISCSIADM -m node -p $portal -T $target -o update -n node.startup -v onboot + # use session number to find the iface name in use + num=${num#[}; num=${num%]} + iface=$(iscsiadm -m session -r $num | grep iface.iscsi_ifacename | cut -d= -f2) + + $ISCSIADM -m node -p $portal -T $target -I $iface -o update -n node.startup -v onboot start_iscsid=1 diff --git a/etc/systemd/iscsi-onboot.service b/etc/systemd/iscsi-onboot.service new file mode 100644 index 0000000..42ced68 --- /dev/null +++ b/etc/systemd/iscsi-onboot.service @@ -0,0 +1,15 @@ +[Unit] +Description=Special handling of early boot iSCSI sessions +Documentation=man:iscsiadm(8) man:iscsid(8) +DefaultDependencies=no +RefuseManualStart=true +Before=iscsi.service +After=systemd-remount-fs.service +ConditionDirectoryNotEmpty=/sys/class/iscsi_session + +[Service] +Type=oneshot +ExecStart=-/usr/libexec/iscsi-mark-root-nodes + +[Install] +WantedBy=sysinit.target diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service index f09b3a0..1d52882 100644 --- a/etc/systemd/iscsi.service +++ b/etc/systemd/iscsi.service @@ -2,21 +2,17 @@ Description=Login and scanning of iSCSI devices Documentation=man:iscsiadm(8) man:iscsid(8) DefaultDependencies=no -Conflicts=shutdown.target Before=remote-fs-pre.target After=network.target network-online.target iscsid.service iscsiuio.service systemd-remount-fs.service Wants=remote-fs-pre.target iscsi-shutdown.service -ConditionPathExists=/etc/iscsi/initiatorname.iscsi -ConditionDirectoryNotEmpty=|/var/lib/iscsi/nodes -ConditionDirectoryNotEmpty=|/sys/class/iscsi_session +ConditionDirectoryNotEmpty=/var/lib/iscsi/nodes [Service] Type=oneshot -ExecStart=-/usr/libexec/iscsi-mark-root-nodes +RemainAfterExit=true ExecStart=-/sbin/iscsiadm -m node --loginall=automatic ExecReload=-/sbin/iscsiadm -m node --loginall=automatic SuccessExitStatus=21 -RemainAfterExit=true [Install] WantedBy=remote-fs.target -- 2.21.0