core/mount,swap: reload unit when manually mounted/started and we previously failed to load

Otherwise, neither unit_patch_contexts() nor unit_add_exec_dependencies()
is called for the unit.
This commit is contained in:
Yu Watanabe
2025-05-11 03:32:48 +09:00
parent 13208591db
commit fee2f5ca3f
2 changed files with 9 additions and 7 deletions
+4 -2
View File
@@ -1855,9 +1855,11 @@ static int mount_setup_existing_unit(
if (UNIT_IS_LOAD_ERROR(u->load_state)) {
/* The unit was previously not found or otherwise not loaded. Now that the unit shows up in
* /proc/self/mountinfo we should reconsider it this, hence set it to UNIT_LOADED. */
u->load_state = UNIT_LOADED;
* /proc/self/mountinfo we should reconsider that. Hence, let's reset the load state and load
* error, and add the unit to load queue. */
u->load_state = UNIT_STUB;
u->load_error = 0;
unit_add_to_load_queue(u);
flags |= MOUNT_PROC_JUST_CHANGED;
}
+5 -5
View File
@@ -406,8 +406,6 @@ static int swap_setup_unit(
s->what = strdup(what);
if (!s->what)
return log_oom();
unit_add_to_load_queue(u);
}
SwapParameters *p = &s->parameters_proc_swaps;
@@ -418,13 +416,15 @@ static int swap_setup_unit(
return log_oom();
}
/* The unit is definitely around now, mark it as loaded if it was previously referenced but
* could not be loaded. After all we can load it now, from the data in /proc/swaps. */
/* The unit is definitely around now. When we previously fail to load the unit, let's reload the unit
* by resetting the load state and load error, and adding the unit to the load queue. */
if (UNIT_IS_LOAD_ERROR(u->load_state)) {
u->load_state = UNIT_LOADED;
u->load_state = UNIT_STUB;
u->load_error = 0;
}
unit_add_to_load_queue(u);
if (set_flags) {
s->is_active = true;
s->just_activated = !s->from_proc_swaps;