From: Yu Watanabe Date: Sat, 10 May 2025 07:11:37 +0000 (+0900) Subject: core/mount,swap: reload unit when manually mounted/started and we previously failed... X-Git-Tag: v258-rc1~645^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fee2f5ca3fc64c343806323548360dbca38cbcea;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/mount.c b/src/core/mount.c index c496375a212..2541a4888c1 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -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; } diff --git a/src/core/swap.c b/src/core/swap.c index 6d505c2acfd..668e1bcf6cb 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -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;