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.
This commit is contained in:
Yu Watanabe
2025-05-11 03:33:02 +09:00
parent fee2f5ca3f
commit 26186503d7
+3 -7
View File
@@ -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;