]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
swap: when loading a unit from /proc/swaps, mark its load state as good
authorLennart Poettering <lennart@poettering.net>
Wed, 28 Nov 2018 19:23:32 +0000 (20:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Dec 2018 16:35:32 +0000 (17:35 +0100)
This follows similar logic in the mount unit.

src/core/swap.c

index 8370414b79b49a3c20e61f4aafd50649159d8755..d91132fabd28d907f4c0dc88323f4ecf1dc40551 100644 (file)
@@ -383,7 +383,6 @@ static int swap_setup_unit(
                 return log_unit_error_errno(u, r, "Failed to generate unit name from path: %m");
 
         u = manager_get_unit(m, e);
-
         if (u &&
             SWAP(u)->from_proc_swaps &&
             !path_equal(SWAP(u)->parameters_proc_swaps.what, what_proc_swaps))
@@ -418,6 +417,13 @@ static int swap_setup_unit(
                 }
         }
 
+        /* 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. */
+        if (IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_BAD_SETTING, UNIT_ERROR)) {
+                u->load_state = UNIT_LOADED;
+                u->load_error = 0;
+        }
+
         if (set_flags) {
                 SWAP(u)->is_active = true;
                 SWAP(u)->just_activated = !SWAP(u)->from_proc_swaps;