iscsi-initiator-utils/SOURCES/0001-service-file-tweaks.patch

147 lines
4.3 KiB
Diff
Raw Normal View History

From efba620a01a2c2fa57b672bced47e88f25078b00 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Tue, 4 Jun 2019 13:23:32 -0700
Subject: [PATCH] service file tweaks
---
etc/systemd/iscsi-mark-root-nodes | 30 ++++++++++++++++++++++++++++++
etc/systemd/iscsi-shutdown.service | 14 ++++++++++++++
etc/systemd/iscsi.service | 23 +++++++++++++----------
etc/systemd/iscsid.service | 6 ++++--
etc/systemd/iscsiuio.service | 2 +-
5 files changed, 62 insertions(+), 13 deletions(-)
create mode 100755 etc/systemd/iscsi-mark-root-nodes
create mode 100644 etc/systemd/iscsi-shutdown.service
diff --git a/etc/systemd/iscsi-mark-root-nodes b/etc/systemd/iscsi-mark-root-nodes
new file mode 100755
index 0000000..c693707
--- /dev/null
+++ b/etc/systemd/iscsi-mark-root-nodes
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+ISCSIADM=/usr/sbin/iscsiadm
+start_iscsid=0
+start_iscsiuio=0
+
+while read t num p target flash; do
+ # strip tag number from portal, keep "ip:port"
+ portal=${p%,*}
+ transport=${t%:}
+
+ $ISCSIADM -m node -p $portal -T $target -o update -n node.startup -v onboot
+
+ start_iscsid=1
+
+ if [ "$transport" = bnx2i ] || [ "$transport" = qedi ]; then
+ start_iscsiuio=1
+ fi
+done < <( $ISCSIADM -m session )
+
+# force iscsid and iscsiuio to start if needed for
+# recovering sessions created in the initrd
+
+if [ "$start_iscsid" -eq 1 ]; then
+ systemctl --no-block start iscsid.service
+fi
+if [ "$start_iscsiuio" -eq 1 ]; then
+ systemctl --no-block start iscsiuio.service
+fi
+
diff --git a/etc/systemd/iscsi-shutdown.service b/etc/systemd/iscsi-shutdown.service
new file mode 100644
index 0000000..69c1c77
--- /dev/null
+++ b/etc/systemd/iscsi-shutdown.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Logout off all iSCSI sessions on shutdown
+Documentation=man:iscsid(8) man:iscsiadm(8)
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
+Before=remote-fs-pre.target
+Wants=remote-fs-pre.target
+RefuseManualStop=yes
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStop=-/usr/sbin/iscsiadm -m node --logoutall=all
diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service
index e475888..eadfcec 100644
--- a/etc/systemd/iscsi.service
+++ b/etc/systemd/iscsi.service
@@ -1,18 +1,21 @@
[Unit]
Description=Login and scanning of iSCSI devices
-Documentation=man:iscsiadm(8) man:iscsid(8)
-Before=remote-fs.target
-After=network.target network-online.target iscsid.service
-Requires=iscsid.service
-ConditionPathExists=/etc/iscsi/initiatorname.iscsi
+Documentation=man:iscsid(8) man:iscsiadm(8)
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
+Before=remote-fs-pre.target
+Wants=remote-fs-pre.target iscsi-shutdown.service
+ConditionDirectoryNotEmpty=|/var/lib/iscsi/nodes
+ConditionDirectoryNotEmpty=|/sys/class/iscsi_session
[Service]
Type=oneshot
-ExecStart=/sbin/iscsiadm -m node --loginall=automatic
-ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
-ExecStop=/sbin/iscsiadm -m node --logoutall=manual
-SuccessExitStatus=21
RemainAfterExit=true
+ExecStart=-/usr/libexec/iscsi-mark-root-nodes
+ExecStart=-/usr/sbin/iscsiadm -m node --loginall=automatic
+ExecReload=-/usr/sbin/iscsiadm -m node --loginall=automatic
+SuccessExitStatus=21
[Install]
-WantedBy=remote-fs.target
+WantedBy=sysinit.target
diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service
index 4fef168..8d50cf0 100644
--- a/etc/systemd/iscsid.service
+++ b/etc/systemd/iscsid.service
@@ -1,14 +1,16 @@
[Unit]
Description=Open-iSCSI
-Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8)
+Documentation=man:iscsid(8) man:iscsiadm(8)
DefaultDependencies=no
+Conflicts=shutdown.target
After=network.target iscsiuio.service
Before=remote-fs-pre.target
[Service]
Type=notify
NotifyAccess=main
-ExecStart=/sbin/iscsid -f
+ExecStart=/usr/sbin/iscsid -f
+ExecStop=/usr/sbin/iscsiadm -k 0 2
KillMode=mixed
Restart=on-failure
diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service
index e4d9fd0..8620cde 100644
--- a/etc/systemd/iscsiuio.service
+++ b/etc/systemd/iscsiuio.service
@@ -11,7 +11,7 @@ Before=remote-fs-pre.target iscsid.service
[Service]
Type=notify
NotifyAccess=main
-ExecStart=/sbin/iscsiuio -f
+ExecStart=/usr/sbin/iscsiuio -f
KillMode=mixed
Restart=on-failure
--
2.21.0