]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/unit: rename freezer "target" to "objective"
authorMike Yuan <me@yhndnzj.com>
Sat, 25 May 2024 10:44:51 +0000 (18:44 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Jul 2025 11:08:03 +0000 (13:08 +0200)
(cherry picked from commit f27f461b01926f08e9d1e88833b69b9b2ba4995c)

src/core/cgroup.c
src/core/unit.c
src/core/unit.h

index 55bdec2acc92ce267b5fbc168554f11d3d2b1f51..381874b2be4a18b872744e07409fb17569f4ea31 100644 (file)
@@ -5123,7 +5123,7 @@ static int unit_cgroup_freezer_kernel_state(Unit *u, FreezerState *ret) {
 
 int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
         _cleanup_free_ char *path = NULL;
-        FreezerState target, current, next;
+        FreezerState current, next, objective;
         int r;
 
         assert(u);
@@ -5133,7 +5133,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
         if (!cg_freezer_supported())
                 return 0;
 
-        unit_next_freezer_state(u, action, &next, &target);
+        unit_next_freezer_state(u, action, &next, &objective);
 
         CGroupRuntime *crt = unit_get_cgroup_runtime(u);
         if (!crt || !crt->cgroup_path) {
@@ -5146,11 +5146,11 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
         if (r < 0)
                 return r;
 
-        if (current == target)
+        if (current == objective)
                 next = freezer_state_finish(next);
         else if (IN_SET(next, FREEZER_FROZEN, FREEZER_FROZEN_BY_PARENT, FREEZER_RUNNING)) {
                 /* We're transitioning into a finished state, which implies that the cgroup's
-                 * current state already matches the target and thus we'd return 0. But, reality
+                 * current state already matches the objective and thus we'd return 0. But, reality
                  * shows otherwise. This indicates that our freezer_state tracking has diverged
                  * from the real state of the cgroup, which can happen if someone meddles with the
                  * cgroup from underneath us. This really shouldn't happen during normal operation,
@@ -5175,12 +5175,12 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
                        freezer_state_to_string(u->freezer_state),
                        freezer_state_to_string(next));
 
-        r = write_string_file(path, one_zero(target == FREEZER_FROZEN), WRITE_STRING_FILE_DISABLE_BUFFER);
+        r = write_string_file(path, one_zero(objective == FREEZER_FROZEN), WRITE_STRING_FILE_DISABLE_BUFFER);
         if (r < 0)
                 return r;
 
         u->freezer_state = next;
-        return target != current;
+        return current != objective;
 }
 
 int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name) {
index b1a65d9bddec8162e05abb77aa1012538561da1d..eb814ac758ad837e4b96a22f73765222aa0fd149 100644 (file)
@@ -6188,26 +6188,26 @@ bool unit_can_isolate_refuse_manual(Unit *u) {
         return unit_can_isolate(u) && !u->refuse_manual_start;
 }
 
-void unit_next_freezer_state(Unit *u, FreezerAction action, FreezerState *ret, FreezerState *ret_target) {
-        Unit *slice;
-        FreezerState curr, parent, next, tgt;
+void unit_next_freezer_state(Unit *u, FreezerAction action, FreezerState *ret, FreezerState *ret_objective) {
+        FreezerState curr, parent, next, objective;
 
         assert(u);
         assert(IN_SET(action, FREEZER_FREEZE, FREEZER_PARENT_FREEZE,
                               FREEZER_THAW, FREEZER_PARENT_THAW));
         assert(ret);
-        assert(ret_target);
+        assert(ret_objective);
 
         /* This function determines the correct freezer state transitions for a unit
-         * given the action being requested. It returns the next state, and also the "target",
+         * given the action being requested. It returns the next state, and also the "objective",
          * which is either FREEZER_FROZEN or FREEZER_RUNNING, depending on what actual state we
          * ultimately want to achieve. */
 
-         curr = u->freezer_state;
-         slice = UNIT_GET_SLICE(u);
-         if (slice)
+        curr = u->freezer_state;
+
+        Unit *slice = UNIT_GET_SLICE(u);
+        if (slice)
                 parent = slice->freezer_state;
-         else
+        else
                 parent = FREEZER_RUNNING;
 
         if (action == FREEZER_FREEZE) {
@@ -6251,13 +6251,13 @@ void unit_next_freezer_state(Unit *u, FreezerAction action, FreezerState *ret, F
                         next = FREEZER_THAWING;
         }
 
-        tgt = freezer_state_finish(next);
-        if (tgt == FREEZER_FROZEN_BY_PARENT)
-                tgt = FREEZER_FROZEN;
-        assert(IN_SET(tgt, FREEZER_RUNNING, FREEZER_FROZEN));
+        objective = freezer_state_finish(next);
+        if (objective == FREEZER_FROZEN_BY_PARENT)
+                objective = FREEZER_FROZEN;
+        assert(IN_SET(objective, FREEZER_RUNNING, FREEZER_FROZEN));
 
         *ret = next;
-        *ret_target = tgt;
+        *ret_objective = objective;
 }
 
 bool unit_can_freeze(Unit *u) {
index 9db6f566ca427984c96c719a1ddbc28063487e1c..a852580098887bba3f25c216550b378ad7e4537d 100644 (file)
@@ -1040,7 +1040,7 @@ bool unit_can_isolate_refuse_manual(Unit *u);
 
 bool unit_can_freeze(Unit *u);
 int unit_freezer_action(Unit *u, FreezerAction action);
-void unit_next_freezer_state(Unit *u, FreezerAction a, FreezerState *ret, FreezerState *ret_tgt);
+void unit_next_freezer_state(Unit *u, FreezerAction a, FreezerState *ret, FreezerState *ret_objective);
 void unit_frozen(Unit *u);
 void unit_thawed(Unit *u);