1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

mount: regenerate all deps whenever a mount's parameters changes

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.
This commit is contained in:
Lennart Poettering 2018-11-28 14:56:27 +01:00
parent 6d7e89b070
commit a37422045f

View 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;
}