From: Yu Watanabe Date: Sat, 10 May 2025 18:22:04 +0000 (+0900) Subject: core/mount: drop unnecessary dependency generations X-Git-Tag: v258-rc1~645^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26186503d71837de829c49b29ae29529bf447097;p=thirdparty%2Fsystemd.git core/mount: drop unnecessary dependency generations When the unit is new, then mount_setup_new_unit() adds the unit to the load queue, and the same dependencies will be anyway added. When the unit already exists but previously failed to be loaded, then mount_setup_existing_unit() also adds the unit to the load queue. Hence it is not necessary to regenerate dependencies here now. So, we need to regenerate dependencies only when things changed and the unit has been already loaded. No functional changes, just optimization. --- diff --git a/src/core/mount.c b/src/core/mount.c index 2541a4888c1..d7211de0249 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1795,10 +1795,6 @@ static int mount_setup_new_unit( * attributes the deps to. */ mnt->from_proc_self_mountinfo = true; - r = mount_add_non_exec_dependencies(mnt); - if (r < 0) - return r; - /* We have only allocated the stub now, let's enqueue this unit for loading now, so that everything * else is loaded in now. */ unit_add_to_load_queue(u); @@ -1864,9 +1860,9 @@ static int mount_setup_existing_unit( flags |= MOUNT_PROC_JUST_CHANGED; } - if (FLAGS_SET(flags, MOUNT_PROC_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. */ + if (FLAGS_SET(flags, MOUNT_PROC_JUST_CHANGED) && u->load_state == UNIT_LOADED) { + /* If things changed, and we have successfully loaded the unit, then make sure that all deps + * are regenerated. Let's first remove all automatic deps, and then add in the new ones. */ r = mount_add_non_exec_dependencies(m); if (r < 0) return r;