]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount: regenerate all deps whenever a mount's parameters changes
authorLennart Poettering <lennart@poettering.net>
Wed, 28 Nov 2018 13:56:27 +0000 (14:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Dec 2018 16:35:32 +0000 (17:35 +0100)
Whenever we notice a change on an existing /proc/self/mountinfo line,
let's update the deps generated from it. For that, let's flush out the
old deps generated this way, and add in the new ones.

This takes benefit of the fact that today (unlike a comment this patch
removes says) we can remove deps in a somewhat reasonable way.

src/core/mount.c

index 599e3b24fe6f4d9849c1b9c511d10041f2f27ecb..d0352c933f92fa0cd55a10f69f4dacd11614f842 100644 (file)
@@ -1512,8 +1512,6 @@ static int mount_setup_existing_unit(
                 const char *fstype,
                 MountSetupFlags *flags) {
 
-        bool load_extras = false;
-        MountParameters *p;
         int r;
 
         assert(u);
@@ -1535,35 +1533,23 @@ static int mount_setup_existing_unit(
 
         MOUNT(u)->from_proc_self_mountinfo = true;
 
-        p = &MOUNT(u)->parameters_proc_self_mountinfo;
-
-        if (!mount_is_extrinsic(MOUNT(u)) && mount_is_network(p)) {
-                /* _netdev option may have shown up late, or on a
-                 * remount. Add remote-fs dependencies, even though
-                 * local-fs ones may already be there.
-                 *
-                 * Note: due to a current limitation (we don't track
-                 * in the dependency "Set*" objects who created a
-                 * dependency), we can only add deps, never lose them,
-                 * until the next full daemon-reload. */
-                unit_add_dependency_by_name(u, UNIT_BEFORE, SPECIAL_REMOTE_FS_TARGET, true, UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT);
-                load_extras = true;
-        }
-
         if (u->load_state == UNIT_NOT_FOUND) {
                 u->load_state = UNIT_LOADED;
                 u->load_error = 0;
 
-                /* Load in the extras later on, after we
-                 * finished initialization of the unit */
-
-                /* FIXME: since we're going to load the unit later on, why setting load_extras=true ? */
-                load_extras = true;
                 flags->just_changed = true;
         }
 
-        if (load_extras)
-                return mount_add_extras(MOUNT(u));
+        if (flags->just_changed) {
+                /* If things changed, then make sure that all deps are regenerated. Let's
+                 * first remove all automatic deps, and then add in the new ones. */
+
+                unit_remove_dependencies(u, UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT);
+
+                r = mount_add_extras(MOUNT(u));
+                if (r < 0)
+                        return r;
+        }
 
         return 0;
 }