]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-generator: extra dependencies specified in fstab should be applied to the mount...
authorFranck Bui <fbui@suse.com>
Thu, 11 Jun 2020 07:41:14 +0000 (09:41 +0200)
committerFranck Bui <fbui@suse.com>
Wed, 1 Jul 2020 14:34:42 +0000 (16:34 +0200)
If an entry in fstab uses "x-systemd.automount" option and also asks for
additionnal dependencies via x-systemd.requires or such, then the dependencies
were applied to the automount unit.

But this unlikely to do the right thing and is inconsistent with what's done
for network mounts.

Indeed when an fstab entries has "_netdev,x-systemd.automount" options, the
dependencies against the network requested by "_netdev" are (correctly) applied
to the mount unit only and the automount unit remains ordered against
local-fs.target.

The same logic should be followed when extra deps are specified via the mount
options as automount units should always be ordered against local-fs.target.

Note: in general explicit deps specified via mount options should be used with
care and should be used to specify dependencies on other mount units only as it
can easily create ordering cycles otherwise like it's been seen in
https://github.com/systemd/systemd-stable/issues/69. Mount units (as well as
automount ones) are ordered before local-fs.target by default which is a
low-level target that most other units depend on.

man/systemd.mount.xml
src/fstab-generator/fstab-generator.c

index 07feccb54a06a38869c754888e2dc61f3a8c9634..33d861a33f92d337f069e46e456398ff3500eb1d 100644 (file)
         system that merges multiple mount points). See
         <varname>After=</varname> and <varname>Requires=</varname> in
         <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-        for details.</para></listitem>
+        for details.</para>
+
+        <para>Note that this option always applies to the created mount unit
+        only regardless whether <option>x-systemd.automount</option> has been
+        specified.</para></listitem>
       </varlistentry>
 
       <varlistentry>
         unit.
         See <varname>Before=</varname> and <varname>After=</varname> in
         <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-        for details.</para></listitem>
+        for details.</para>
+
+        <para>Note that these options always apply to the created mount unit
+        only regardless whether <option>x-systemd.automount</option> has been
+        specified.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index 77b90e1a9b808b573d84a995167f60d186e6cee4..39e91a9c6b5b2a39ff805975c97e6a013b787250 100644 (file)
@@ -406,7 +406,7 @@ static int add_mount(
                 SET_FLAG(flags, NOFAIL, true);
         }
 
-        if (!(flags & AUTOMOUNT) && opts) {
+        if (opts) {
                  r = write_after(f, opts);
                  if (r < 0)
                          return r;
@@ -530,21 +530,6 @@ static int add_mount(
                         "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n",
                         source);
 
-                if (opts) {
-                        r = write_after(f, opts);
-                        if (r < 0)
-                                return r;
-                        r = write_requires_after(f, opts);
-                        if (r < 0)
-                                return r;
-                        r = write_before(f, opts);
-                        if (r < 0)
-                                return r;
-                        r = write_requires_mounts_for(f, opts);
-                        if (r < 0)
-                                return r;
-                }
-
                 fprintf(f,
                         "\n"
                         "[Automount]\n"