diff --git a/src/core/mount.c b/src/core/mount.c index 599e3b24fe..d0352c933f 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -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; }