From: Lennart Poettering Date: Wed, 28 Nov 2018 13:56:27 +0000 (+0100) Subject: mount: regenerate all deps whenever a mount's parameters changes X-Git-Tag: v240~112^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a37422045fbb68ad68f734e5dc00e0a5b1759773;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/mount.c b/src/core/mount.c index 599e3b24fe6..d0352c933f9 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; }