]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: make "tmpfs" dependencies on swapfs a "default" dep, not an "implicit"
authorLennart Poettering <lennart@poettering.net>
Thu, 26 Oct 2017 15:24:55 +0000 (17:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 10 Nov 2017 18:52:41 +0000 (19:52 +0100)
There should be a way to turn this logic of, and DefaultDependencies=
appears to be the right option for that, hence let's downgrade this
dependency type from "implicit" to "default, and thus honour
DefaultDependencies=.

This also drops mount_get_fstype() as we only have a single user needing
this now.

A follow-up for #7076.

src/core/dbus-mount.c
src/core/mount.c
src/core/mount.h
units/tmp.mount

index 1f9c254c3923179dea231186aff2e3ae8b8c06b9..c683b36c4c1448560b06c8b66d00b64b846bbad2 100644 (file)
@@ -87,13 +87,19 @@ static int property_get_type(
                 void *userdata,
                 sd_bus_error *error) {
 
+        const char *fstype = NULL;
         Mount *m = userdata;
 
         assert(bus);
         assert(reply);
         assert(m);
 
-        return sd_bus_message_append(reply, "s", mount_get_fstype(m));
+        if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.fstype)
+                fstype = m->parameters_proc_self_mountinfo.fstype;
+        else if (m->from_fragment && m->parameters_fragment.fstype)
+                fstype = m->parameters_fragment.fstype;
+
+        return sd_bus_message_append(reply, "s", fstype);
 }
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, mount_result, MountResult);
index 343e17fa1047bdecda50232c6bb11a2ce27a5b6c..214b46f6703e7377cc307ff14e8e699e8c9144e4 100644 (file)
@@ -156,21 +156,6 @@ static bool needs_quota(const MountParameters *p) {
                                  "usrquota\0" "grpquota\0" "quota\0" "usrjquota\0" "grpjquota\0");
 }
 
-const char *mount_get_fstype(const Mount *m) {
-        const char *type = NULL;
-
-        assert(m);
-
-        if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.fstype)
-                type = m->parameters_proc_self_mountinfo.fstype;
-        else if (m->from_fragment && m->parameters_fragment.fstype)
-                type = m->parameters_fragment.fstype;
-        else
-                type = "";
-
-        return type;
-}
-
 static void mount_init(Unit *u) {
         Mount *m = MOUNT(u);
 
@@ -281,7 +266,6 @@ _pure_ static MountParameters* get_mount_parameters(Mount *m) {
 }
 
 static int mount_add_mount_dependencies(Mount *m) {
-        const char *fstype;
         MountParameters *pm;
         Unit *other;
         Iterator i;
@@ -338,14 +322,6 @@ static int mount_add_mount_dependencies(Mount *m) {
                 }
         }
 
-        /* If this is a tmpfs mount then we have to unmount it before we try to deactivate swaps */
-        fstype = mount_get_fstype(m);
-        if (streq(fstype, "tmpfs")) {
-                r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SWAP_TARGET, NULL, true, UNIT_DEPENDENCY_IMPLICIT);
-                if (r < 0)
-                        return r;
-        }
-
         return 0;
 }
 
@@ -517,6 +493,13 @@ static int mount_add_default_dependencies(Mount *m) {
         if (r < 0)
                 return r;
 
+        /* If this is a tmpfs mount then we have to unmount it before we try to deactivate swaps */
+        if (streq(p->fstype, "tmpfs")) {
+                r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SWAP_TARGET, NULL, true, mask);
+                if (r < 0)
+                        return r;
+        }
+
         return 0;
 }
 
index f37094e39f1b8f9c8d3bc111337231853f8c5a3a..f81e4217dfbb3431814e1b03638e8f94db9f4520 100644 (file)
@@ -110,5 +110,3 @@ MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
 
 const char* mount_result_to_string(MountResult i) _const_;
 MountResult mount_result_from_string(const char *s) _pure_;
-
-const char *mount_get_fstype(const Mount *m);
index a057fa1cf9e187b4d3ca6e2d3fd88bb7187926b7..3a333d22ecd47f72ed8496986c282c2c5fc063c8 100644 (file)
@@ -13,6 +13,7 @@ ConditionPathIsSymbolicLink=!/tmp
 DefaultDependencies=no
 Conflicts=umount.target
 Before=local-fs.target umount.target
+After=swap.target
 
 [Mount]
 What=tmpfs