Zbigniew Jędrzejewski-Szmek ca246f
From a0dd209763f9e67054ee322a2dfd52bccf345c2e Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek ca246f
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Zbigniew Jędrzejewski-Szmek ca246f
Date: Thu, 12 Oct 2017 22:34:54 +0200
Zbigniew Jędrzejewski-Szmek ca246f
Subject: [PATCH] units: replace remote-cryptsetup-pre.target with
Zbigniew Jędrzejewski-Szmek ca246f
 remote-fs-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
Zbigniew Jędrzejewski-Szmek ca246f
remote-cryptsetup-pre.target was designed as an active unit (that pulls in
Zbigniew Jędrzejewski-Szmek ca246f
network-online.target), the opposite of remote-fs-pre.target (a passive unit,
Zbigniew Jędrzejewski-Szmek ca246f
with individual provider services ordering itself before it and pulling it in,
Zbigniew Jędrzejewski-Szmek ca246f
for example iscsi.service and nfs-client.target).
Zbigniew Jędrzejewski-Szmek ca246f
Zbigniew Jędrzejewski-Szmek ca246f
To make remote-cryptsetup-pre.target really work, those services should be
Zbigniew Jędrzejewski-Szmek ca246f
ordered before it too. But this would require updates to all those services,
Zbigniew Jędrzejewski-Szmek ca246f
not just changes from systemd side.
Zbigniew Jędrzejewski-Szmek ca246f
Zbigniew Jędrzejewski-Szmek ca246f
But the requirements for remote-fs-pre.target and remote-cryptset-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
are fairly similar (e.g. iscsi devices can certainly be used for both), so
Zbigniew Jędrzejewski-Szmek ca246f
let's reuse remote-fs-pre.target also for remote cryptsetup units. This loses
Zbigniew Jędrzejewski-Szmek ca246f
a bit of flexibility, but does away with the requirement for various provider
Zbigniew Jędrzejewski-Szmek ca246f
services to know about remote-cryptsetup-pre.target.
Zbigniew Jędrzejewski-Szmek ca246f
---
Zbigniew Jędrzejewski-Szmek ca246f
 man/crypttab.xml                      |  2 +-
Zbigniew Jędrzejewski-Szmek ca246f
 man/systemd.special.xml               | 20 ++++----------------
Zbigniew Jędrzejewski-Szmek ca246f
 src/cryptsetup/cryptsetup-generator.c |  2 +-
Zbigniew Jędrzejewski-Szmek ca246f
 units/meson.build                     |  1 -
Zbigniew Jędrzejewski-Szmek ca246f
 units/remote-cryptsetup-pre.target    | 15 ---------------
Zbigniew Jędrzejewski-Szmek ca246f
 units/remote-cryptsetup.target        |  2 +-
Zbigniew Jędrzejewski-Szmek ca246f
 6 files changed, 7 insertions(+), 35 deletions(-)
Zbigniew Jędrzejewski-Szmek ca246f
 delete mode 100644 units/remote-cryptsetup-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
Zbigniew Jędrzejewski-Szmek ca246f
diff --git a/man/crypttab.xml b/man/crypttab.xml
Zbigniew Jędrzejewski-Szmek ca246f
index ac7d55271c..caed04836e 100644
Zbigniew Jędrzejewski-Szmek ca246f
--- a/man/crypttab.xml
Zbigniew Jędrzejewski-Szmek ca246f
+++ b/man/crypttab.xml
Zbigniew Jędrzejewski-Szmek ca246f
@@ -198,7 +198,7 @@
Zbigniew Jędrzejewski-Szmek ca246f
         started after the network is available, similarly to
Zbigniew Jędrzejewski-Szmek ca246f
         <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Zbigniew Jędrzejewski-Szmek ca246f
         units marked with <option>_netdev</option>. The service unit to set up this device
Zbigniew Jędrzejewski-Szmek ca246f
-        will be ordered between <filename>remote-cryptsetup-pre.target</filename> and
Zbigniew Jędrzejewski-Szmek ca246f
+        will be ordered between <filename>remote-fs-pre.target</filename> and
Zbigniew Jędrzejewski-Szmek ca246f
         <filename>remote-cryptsetup.target</filename>, instead of
Zbigniew Jędrzejewski-Szmek ca246f
         <filename>cryptsetup-pre.target</filename> and
Zbigniew Jędrzejewski-Szmek ca246f
         <filename>cryptsetup.target</filename>.</para></listitem>
Zbigniew Jędrzejewski-Szmek ca246f
diff --git a/man/systemd.special.xml b/man/systemd.special.xml
Zbigniew Jędrzejewski-Szmek ca246f
index 69c24c3979..bb0c796377 100644
Zbigniew Jędrzejewski-Szmek ca246f
--- a/man/systemd.special.xml
Zbigniew Jędrzejewski-Szmek ca246f
+++ b/man/systemd.special.xml
Zbigniew Jędrzejewski-Szmek ca246f
@@ -81,7 +81,6 @@
Zbigniew Jędrzejewski-Szmek ca246f
     <filename>poweroff.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
     <filename>printer.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
     <filename>reboot.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
-    <filename>remote-cryptsetup-pre.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
     <filename>remote-cryptsetup.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
     <filename>remote-fs-pre.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
     <filename>remote-fs.target</filename>,
Zbigniew Jędrzejewski-Szmek ca246f
@@ -494,18 +493,6 @@
Zbigniew Jędrzejewski-Szmek ca246f
           this target unit, for compatibility with SysV.</para>
Zbigniew Jędrzejewski-Szmek ca246f
         </listitem>
Zbigniew Jędrzejewski-Szmek ca246f
       </varlistentry>
Zbigniew Jędrzejewski-Szmek ca246f
-      <varlistentry>
Zbigniew Jędrzejewski-Szmek ca246f
-        <term><filename>remote-cryptsetup-pre.target</filename></term>
Zbigniew Jędrzejewski-Szmek ca246f
-        <listitem>
Zbigniew Jędrzejewski-Szmek ca246f
-          <para>This target unit is automatically ordered before all cryptsetup devices
Zbigniew Jędrzejewski-Szmek ca246f
-          marked with the <option>_netdev</option>. It can be used to execute additional
Zbigniew Jędrzejewski-Szmek ca246f
-          units before such devices are set up.</para>
Zbigniew Jędrzejewski-Szmek ca246f
-
Zbigniew Jędrzejewski-Szmek ca246f
-          <para>It is ordered after <filename>network.target</filename> and
Zbigniew Jędrzejewski-Szmek ca246f
-          <filename>network-online.target</filename>, and also pulls the latter in as a
Zbigniew Jędrzejewski-Szmek ca246f
-          <varname>Wants=</varname> dependency.</para>
Zbigniew Jędrzejewski-Szmek ca246f
-        </listitem>
Zbigniew Jędrzejewski-Szmek ca246f
-      </varlistentry>
Zbigniew Jędrzejewski-Szmek ca246f
       <varlistentry>
Zbigniew Jędrzejewski-Szmek ca246f
         <term><filename>remote-cryptsetup.target</filename></term>
Zbigniew Jędrzejewski-Szmek ca246f
         <listitem>
Zbigniew Jędrzejewski-Szmek ca246f
@@ -906,9 +893,10 @@
Zbigniew Jędrzejewski-Szmek ca246f
         <term><filename>remote-fs-pre.target</filename></term>
Zbigniew Jędrzejewski-Szmek ca246f
         <listitem>
Zbigniew Jędrzejewski-Szmek ca246f
           <para>This target unit is automatically ordered before all
Zbigniew Jędrzejewski-Szmek ca246f
-          remote mount point units (see above). It can be used to run
Zbigniew Jędrzejewski-Szmek ca246f
-          certain units before the remote mounts are established. Note
Zbigniew Jędrzejewski-Szmek ca246f
-          that this unit is generally not part of the initial
Zbigniew Jędrzejewski-Szmek ca246f
+          mount point units (see above) and cryptsetup devices
Zbigniew Jędrzejewski-Szmek ca246f
+          marked with the <option>_netdev</option>. It can be used to run
Zbigniew Jędrzejewski-Szmek ca246f
+          certain units before remote encrypted devices and mounts are established.
Zbigniew Jędrzejewski-Szmek ca246f
+          Note that this unit is generally not part of the initial
Zbigniew Jędrzejewski-Szmek ca246f
           transaction, unless the unit that wants to be ordered before
Zbigniew Jędrzejewski-Szmek ca246f
           all remote mounts pulls it in via a
Zbigniew Jędrzejewski-Szmek ca246f
           <varname>Wants=</varname> type dependency. If the unit wants
Zbigniew Jędrzejewski-Szmek ca246f
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
Zbigniew Jędrzejewski-Szmek ca246f
index 3752ca2ef2..040a1aa408 100644
Zbigniew Jędrzejewski-Szmek ca246f
--- a/src/cryptsetup/cryptsetup-generator.c
Zbigniew Jędrzejewski-Szmek ca246f
+++ b/src/cryptsetup/cryptsetup-generator.c
Zbigniew Jędrzejewski-Szmek ca246f
@@ -113,7 +113,7 @@ static int create_disk(
Zbigniew Jędrzejewski-Szmek ca246f
                 "Conflicts=umount.target\n"
Zbigniew Jędrzejewski-Szmek ca246f
                 "IgnoreOnIsolate=true\n"
Zbigniew Jędrzejewski-Szmek ca246f
                 "After=%s\n",
Zbigniew Jędrzejewski-Szmek ca246f
-                netdev ? "remote-cryptsetup-pre.target" : "cryptsetup-pre.target");
Zbigniew Jędrzejewski-Szmek ca246f
+                netdev ? "remote-fs-pre.target" : "cryptsetup-pre.target");
Zbigniew Jędrzejewski-Szmek ca246f
 
Zbigniew Jędrzejewski-Szmek ca246f
         if (!nofail)
Zbigniew Jędrzejewski-Szmek ca246f
                 fprintf(f,
Zbigniew Jędrzejewski-Szmek ca246f
diff --git a/units/meson.build b/units/meson.build
Zbigniew Jędrzejewski-Szmek ca246f
index 8494d23e9e..4e2ae3f302 100644
Zbigniew Jędrzejewski-Szmek ca246f
--- a/units/meson.build
Zbigniew Jędrzejewski-Szmek ca246f
+++ b/units/meson.build
Zbigniew Jędrzejewski-Szmek ca246f
@@ -48,7 +48,6 @@ units = [
Zbigniew Jędrzejewski-Szmek ca246f
         ['proc-sys-fs-binfmt_misc.mount',       'ENABLE_BINFMT'],
Zbigniew Jędrzejewski-Szmek ca246f
         ['reboot.target',                       '',
Zbigniew Jędrzejewski-Szmek ca246f
          'runlevel6.target ctrl-alt-del.target'],
Zbigniew Jędrzejewski-Szmek ca246f
-        ['remote-cryptsetup-pre.target',        'HAVE_LIBCRYPTSETUP'],
Zbigniew Jędrzejewski-Szmek ca246f
         ['remote-cryptsetup.target',            'HAVE_LIBCRYPTSETUP',
Zbigniew Jędrzejewski-Szmek ca246f
          join_paths(pkgsysconfdir, 'system/multi-user.target.wants/')],
Zbigniew Jędrzejewski-Szmek ca246f
         ['remote-fs-pre.target',                ''],
Zbigniew Jędrzejewski-Szmek ca246f
diff --git a/units/remote-cryptsetup-pre.target b/units/remote-cryptsetup-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
deleted file mode 100644
Zbigniew Jędrzejewski-Szmek ca246f
index a375e61889..0000000000
Zbigniew Jędrzejewski-Szmek ca246f
--- a/units/remote-cryptsetup-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
+++ /dev/null
Zbigniew Jędrzejewski-Szmek ca246f
@@ -1,15 +0,0 @@
Zbigniew Jędrzejewski-Szmek ca246f
-#  This file is part of systemd.
Zbigniew Jędrzejewski-Szmek ca246f
-#
Zbigniew Jędrzejewski-Szmek ca246f
-#  systemd is free software; you can redistribute it and/or modify it
Zbigniew Jędrzejewski-Szmek ca246f
-#  under the terms of the GNU Lesser General Public License as published by
Zbigniew Jędrzejewski-Szmek ca246f
-#  the Free Software Foundation; either version 2.1 of the License, or
Zbigniew Jędrzejewski-Szmek ca246f
-#  (at your option) any later version.
Zbigniew Jędrzejewski-Szmek ca246f
-
Zbigniew Jędrzejewski-Szmek ca246f
-[Unit]
Zbigniew Jędrzejewski-Szmek ca246f
-Description=Remote Encrypted Volumes (Pre)
Zbigniew Jędrzejewski-Szmek ca246f
-Documentation=man:systemd.special(7)
Zbigniew Jędrzejewski-Szmek ca246f
-RefuseManualStart=yes
Zbigniew Jędrzejewski-Szmek ca246f
-Before=remote-cryptsetup.target
Zbigniew Jędrzejewski-Szmek ca246f
-
Zbigniew Jędrzejewski-Szmek ca246f
-After=network.target network-online.target
Zbigniew Jędrzejewski-Szmek ca246f
-Wants=network-online.target
Zbigniew Jędrzejewski-Szmek ca246f
diff --git a/units/remote-cryptsetup.target b/units/remote-cryptsetup.target
Zbigniew Jędrzejewski-Szmek ca246f
index c306d521f7..d485b06726 100644
Zbigniew Jędrzejewski-Szmek ca246f
--- a/units/remote-cryptsetup.target
Zbigniew Jędrzejewski-Szmek ca246f
+++ b/units/remote-cryptsetup.target
Zbigniew Jędrzejewski-Szmek ca246f
@@ -8,7 +8,7 @@
Zbigniew Jędrzejewski-Szmek ca246f
 [Unit]
Zbigniew Jędrzejewski-Szmek ca246f
 Description=Remote Encrypted Volumes
Zbigniew Jędrzejewski-Szmek ca246f
 Documentation=man:systemd.special(7)
Zbigniew Jędrzejewski-Szmek ca246f
-After=remote-cryptsetup-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
+After=remote-fs-pre.target
Zbigniew Jędrzejewski-Szmek ca246f
 DefaultDependencies=no
Zbigniew Jędrzejewski-Szmek ca246f
 Conflicts=shutdown.target
Zbigniew Jędrzejewski-Szmek ca246f