Blame SOURCES/0001-unit-file-tweaks.patch

10df1d
From 28e3ef5c630b8433eaad176a53c98af05a994f36 Mon Sep 17 00:00:00 2001
5f4533
From: rpm-build <rpm-build>
5f4533
Date: Tue, 4 Jun 2019 13:23:32 -0700
10df1d
Subject: [PATCH 01/23] unit file tweaks
5f4533
5f4533
---
9a267a
 etc/systemd/iscsi-mark-root-nodes  | 34 ++++++++++++++++++++++++++++++
9a267a
 etc/systemd/iscsi-onboot.service   | 15 +++++++++++++
9a267a
 etc/systemd/iscsi-shutdown.service | 15 +++++++++++++
9a267a
 etc/systemd/iscsi.service          | 16 +++++++-------
10df1d
 etc/systemd/iscsid.service         |  6 ++----
9a267a
 etc/systemd/iscsiuio.service       |  4 +---
10df1d
 6 files changed, 75 insertions(+), 15 deletions(-)
5f4533
 create mode 100755 etc/systemd/iscsi-mark-root-nodes
9a267a
 create mode 100644 etc/systemd/iscsi-onboot.service
5f4533
 create mode 100644 etc/systemd/iscsi-shutdown.service
5f4533
5f4533
diff --git a/etc/systemd/iscsi-mark-root-nodes b/etc/systemd/iscsi-mark-root-nodes
5f4533
new file mode 100755
9a267a
index 0000000..9d48805
5f4533
--- /dev/null
5f4533
+++ b/etc/systemd/iscsi-mark-root-nodes
9a267a
@@ -0,0 +1,34 @@
5f4533
+#!/bin/bash
5f4533
+
5f4533
+ISCSIADM=/usr/sbin/iscsiadm
5f4533
+start_iscsid=0
5f4533
+start_iscsiuio=0
5f4533
+
5f4533
+while read t num p target flash; do
5f4533
+  # strip tag number from portal, keep "ip:port"
5f4533
+  portal=${p%,*}
5f4533
+  transport=${t%:}
5f4533
+
9a267a
+  # use session number to find the iface name in use
9a267a
+  num=${num#[}; num=${num%]}
9a267a
+  iface=$(iscsiadm -m session -r $num | grep iface.iscsi_ifacename | cut -d= -f2)
9a267a
+
9a267a
+  $ISCSIADM -m node -p $portal -T $target -I $iface -o update -n node.startup -v onboot
5f4533
+
5f4533
+  start_iscsid=1
5f4533
+
5f4533
+  if [ "$transport" = bnx2i ] || [ "$transport" = qedi ]; then
5f4533
+    start_iscsiuio=1
5f4533
+  fi
5f4533
+done < <( $ISCSIADM -m session )
5f4533
+
5f4533
+# force iscsid and iscsiuio to start if needed for
5f4533
+# recovering sessions created in the initrd
5f4533
+
5f4533
+if [ "$start_iscsid" -eq 1 ]; then
5f4533
+  systemctl --no-block start iscsid.service
5f4533
+fi
5f4533
+if [ "$start_iscsiuio" -eq 1 ]; then
5f4533
+  systemctl --no-block start iscsiuio.service
5f4533
+fi
5f4533
+
9a267a
diff --git a/etc/systemd/iscsi-onboot.service b/etc/systemd/iscsi-onboot.service
9a267a
new file mode 100644
9a267a
index 0000000..42ced68
9a267a
--- /dev/null
9a267a
+++ b/etc/systemd/iscsi-onboot.service
9a267a
@@ -0,0 +1,15 @@
9a267a
+[Unit]
9a267a
+Description=Special handling of early boot iSCSI sessions
9a267a
+Documentation=man:iscsiadm(8) man:iscsid(8)
9a267a
+DefaultDependencies=no
9a267a
+RefuseManualStart=true
9a267a
+Before=iscsi.service
9a267a
+After=systemd-remount-fs.service
9a267a
+ConditionDirectoryNotEmpty=/sys/class/iscsi_session
9a267a
+
9a267a
+[Service]
9a267a
+Type=oneshot
9a267a
+ExecStart=-/usr/libexec/iscsi-mark-root-nodes
9a267a
+
9a267a
+[Install]
9a267a
+WantedBy=sysinit.target
5f4533
diff --git a/etc/systemd/iscsi-shutdown.service b/etc/systemd/iscsi-shutdown.service
5f4533
new file mode 100644
9a267a
index 0000000..caee933
5f4533
--- /dev/null
5f4533
+++ b/etc/systemd/iscsi-shutdown.service
9a267a
@@ -0,0 +1,15 @@
5f4533
+[Unit]
5f4533
+Description=Logout off all iSCSI sessions on shutdown
5f4533
+Documentation=man:iscsid(8) man:iscsiadm(8)
5f4533
+DefaultDependencies=no
5f4533
+Conflicts=shutdown.target
5f4533
+After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
5f4533
+Before=remote-fs-pre.target
5f4533
+Wants=remote-fs-pre.target
5f4533
+RefuseManualStop=yes
5f4533
+
5f4533
+[Service]
5f4533
+Type=oneshot
5f4533
+RemainAfterExit=true
9a267a
+ExecStart=-/usr/bin/true
5f4533
+ExecStop=-/usr/sbin/iscsiadm -m node --logoutall=all
5f4533
diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service
10df1d
index 5e394b9..26e557d 100644
5f4533
--- a/etc/systemd/iscsi.service
5f4533
+++ b/etc/systemd/iscsi.service
10df1d
@@ -1,17 +1,17 @@
5f4533
 [Unit]
5f4533
 Description=Login and scanning of iSCSI devices
9a267a
 Documentation=man:iscsiadm(8) man:iscsid(8)
5f4533
-Before=remote-fs.target
10df1d
-After=network-online.target iscsid.service
9a267a
-Requires=iscsid.socket iscsi-init.service
10df1d
-Wants=network-online.target
5f4533
+DefaultDependencies=no
5f4533
+Before=remote-fs-pre.target
9a267a
+After=network.target network-online.target iscsid.service iscsiuio.service systemd-remount-fs.service
10df1d
+Wants=network-online.target remote-fs-pre.target iscsi-shutdown.service
9a267a
+ConditionDirectoryNotEmpty=/var/lib/iscsi/nodes
5f4533
 
5f4533
 [Service]
5f4533
 Type=oneshot
10df1d
-ExecStart=/sbin/iscsiadm -m node --loginall=automatic -W
5f4533
-ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
5f4533
-ExecStop=/sbin/iscsiadm -m node --logoutall=manual
9a267a
-SuccessExitStatus=21 15
5f4533
+ExecStart=-/usr/sbin/iscsiadm -m node --loginall=automatic
5f4533
+ExecReload=-/usr/sbin/iscsiadm -m node --loginall=automatic
5f4533
+SuccessExitStatus=21
10df1d
 RemainAfterExit=true
5f4533
 
5f4533
 [Install]
5f4533
diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service
10df1d
index 3fd7dd3..3958dae 100644
5f4533
--- a/etc/systemd/iscsid.service
5f4533
+++ b/etc/systemd/iscsid.service
10df1d
@@ -2,15 +2,13 @@
10df1d
 Description=Open-iSCSI
10df1d
 Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8)
5f4533
 DefaultDependencies=no
10df1d
-After=network-online.target iscsiuio.service iscsi-init.service
10df1d
+After=network.target network-online.target iscsiuio.service
5f4533
 Before=remote-fs-pre.target
9a267a
-Wants=remote-fs-pre.target
10df1d
-Requires=iscsi-init.service
5f4533
 
5f4533
 [Service]
5f4533
 Type=notify
5f4533
 NotifyAccess=main
5f4533
-ExecStart=/sbin/iscsid -f
5f4533
+ExecStart=/usr/sbin/iscsid -f
5f4533
 KillMode=mixed
5f4533
 Restart=on-failure
5f4533
 
5f4533
diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service
9a267a
index 923e019..fc0be93 100644
5f4533
--- a/etc/systemd/iscsiuio.service
5f4533
+++ b/etc/systemd/iscsiuio.service
9a267a
@@ -2,17 +2,15 @@
9a267a
 Description=iSCSI UserSpace I/O driver
9a267a
 Documentation=man:iscsiuio(8)
9a267a
 DefaultDependencies=no
9a267a
-Conflicts=shutdown.target
9a267a
 Requires=iscsid.service
9a267a
 BindTo=iscsid.service
9a267a
 After=network.target
9a267a
 Before=remote-fs-pre.target iscsid.service
9a267a
-Wants=remote-fs-pre.target
9a267a
 
5f4533
 [Service]
5f4533
 Type=notify
5f4533
 NotifyAccess=main
5f4533
-ExecStart=/sbin/iscsiuio -f
5f4533
+ExecStart=/usr/sbin/iscsiuio -f
5f4533
 KillMode=mixed
5f4533
 Restart=on-failure
5f4533
 
5f4533
-- 
10df1d
2.31.1
5f4533