]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/mount,swap: reload unit when manually mounted/started and we previously failed...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 10 May 2025 07:11:37 +0000 (16:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 10 May 2025 18:32:48 +0000 (03:32 +0900)
Otherwise, neither unit_patch_contexts() nor unit_add_exec_dependencies()
is called for the unit.

src/core/mount.c
src/core/swap.c

index c496375a212b97eb0e59a9b1bc8234ed5d9e3461..2541a4888c1a4eb024e1503d8de9c55fd344b678 100644 (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;
         }
index 6d505c2acfd1effebbf0ba9e1b85593fa908d0fd..668e1bcf6cb8b31d29231d66cfa904a738bc3193 100644 (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;