From 2c0ce41cb82cb1300ceb85c57d897745491a6820 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 14 Oct 2024 19:27:19 +0200 Subject: [PATCH] core: drop effectively unused UNIT_ATOM_PROPAGATE_RESTART Restart jobs are always run as stop jobs initially, and later gets converted to start jobs by job engine. Hence UNIT_ATOM_PROPAGATE_STOP should and does cover the restart case, as currently all dep types with _RESTART also carries _STOP. Drop UNIT_ATOM_PROPAGATE_RESTART. --- src/core/transaction.c | 2 +- src/core/unit-dependency-atom.c | 12 ++--------- src/core/unit-dependency-atom.h | 38 ++++++++++++++++----------------- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/core/transaction.c b/src/core/transaction.c index 9d48768d876..1ab59b823e5 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -1087,7 +1087,7 @@ int transaction_add_job_and_dependencies( if (IN_SET(type, JOB_RESTART, JOB_STOP) || (type == JOB_START && FLAGS_SET(flags, TRANSACTION_PROPAGATE_START_AS_RESTART))) { bool is_stop = type == JOB_STOP; - UNIT_FOREACH_DEPENDENCY(dep, ret->unit, is_stop ? UNIT_ATOM_PROPAGATE_STOP : UNIT_ATOM_PROPAGATE_RESTART) { + UNIT_FOREACH_DEPENDENCY(dep, ret->unit, UNIT_ATOM_PROPAGATE_STOP) { /* We propagate RESTART only as TRY_RESTART, in order not to start dependencies that * are not around. */ JobType nt; diff --git a/src/core/unit-dependency-atom.c b/src/core/unit-dependency-atom.c index 35b279b5c74..aba58612f7c 100644 --- a/src/core/unit-dependency-atom.c +++ b/src/core/unit-dependency-atom.c @@ -33,8 +33,6 @@ static const UnitDependencyAtom atom_map[_UNIT_DEPENDENCY_MAX] = { UNIT_ATOM_ADD_STOP_WHEN_UNNEEDED_QUEUE | UNIT_ATOM_ADD_DEFAULT_TARGET_DEPENDENCY_QUEUE, - [UNIT_PART_OF] = UNIT_ATOM_ADD_DEFAULT_TARGET_DEPENDENCY_QUEUE, - [UNIT_UPHOLDS] = UNIT_ATOM_PULL_IN_START_IGNORED | UNIT_ATOM_RETROACTIVE_START_REPLACE | UNIT_ATOM_ADD_START_WHEN_UPHELD_QUEUE | @@ -42,13 +40,11 @@ static const UnitDependencyAtom atom_map[_UNIT_DEPENDENCY_MAX] = { UNIT_ATOM_ADD_DEFAULT_TARGET_DEPENDENCY_QUEUE, [UNIT_REQUIRED_BY] = UNIT_ATOM_PROPAGATE_STOP | - UNIT_ATOM_PROPAGATE_RESTART | UNIT_ATOM_PROPAGATE_START_FAILURE | UNIT_ATOM_PINS_STOP_WHEN_UNNEEDED | UNIT_ATOM_DEFAULT_TARGET_DEPENDENCIES, [UNIT_REQUISITE_OF] = UNIT_ATOM_PROPAGATE_STOP | - UNIT_ATOM_PROPAGATE_RESTART | UNIT_ATOM_PROPAGATE_START_FAILURE | UNIT_ATOM_PROPAGATE_INACTIVE_START_AS_FAILURE | UNIT_ATOM_PINS_STOP_WHEN_UNNEEDED | @@ -59,7 +55,6 @@ static const UnitDependencyAtom atom_map[_UNIT_DEPENDENCY_MAX] = { [UNIT_BOUND_BY] = UNIT_ATOM_RETROACTIVE_STOP_ON_STOP | UNIT_ATOM_PROPAGATE_STOP | - UNIT_ATOM_PROPAGATE_RESTART | UNIT_ATOM_PROPAGATE_START_FAILURE | UNIT_ATOM_PINS_STOP_WHEN_UNNEEDED | UNIT_ATOM_ADD_CANNOT_BE_ACTIVE_WITHOUT_QUEUE | @@ -69,9 +64,6 @@ static const UnitDependencyAtom atom_map[_UNIT_DEPENDENCY_MAX] = { UNIT_ATOM_DEFAULT_TARGET_DEPENDENCIES | UNIT_ATOM_PINS_STOP_WHEN_UNNEEDED, - [UNIT_CONSISTS_OF] = UNIT_ATOM_PROPAGATE_STOP | - UNIT_ATOM_PROPAGATE_RESTART, - [UNIT_CONFLICTS] = UNIT_ATOM_PULL_IN_STOP | UNIT_ATOM_RETROACTIVE_STOP_ON_START, @@ -89,6 +81,8 @@ static const UnitDependencyAtom atom_map[_UNIT_DEPENDENCY_MAX] = { [UNIT_ON_SUCCESS_OF] = UNIT_ATOM_ON_SUCCESS_OF, [UNIT_BEFORE] = UNIT_ATOM_BEFORE, [UNIT_AFTER] = UNIT_ATOM_AFTER, + [UNIT_PART_OF] = UNIT_ATOM_ADD_DEFAULT_TARGET_DEPENDENCY_QUEUE, + [UNIT_CONSISTS_OF] = UNIT_ATOM_PROPAGATE_STOP, [UNIT_TRIGGERS] = UNIT_ATOM_TRIGGERS, [UNIT_TRIGGERED_BY] = UNIT_ATOM_TRIGGERED_BY, [UNIT_PROPAGATES_RELOAD_TO] = UNIT_ATOM_PROPAGATES_RELOAD_TO, @@ -160,7 +154,6 @@ UnitDependency unit_dependency_from_unique_atom(UnitDependencyAtom atom) { return UNIT_UPHOLDS; case UNIT_ATOM_PROPAGATE_STOP | - UNIT_ATOM_PROPAGATE_RESTART | UNIT_ATOM_PROPAGATE_START_FAILURE | UNIT_ATOM_PROPAGATE_INACTIVE_START_AS_FAILURE | UNIT_ATOM_PINS_STOP_WHEN_UNNEEDED | @@ -170,7 +163,6 @@ UnitDependency unit_dependency_from_unique_atom(UnitDependencyAtom atom) { case UNIT_ATOM_RETROACTIVE_STOP_ON_STOP | UNIT_ATOM_PROPAGATE_STOP | - UNIT_ATOM_PROPAGATE_RESTART | UNIT_ATOM_PROPAGATE_START_FAILURE | UNIT_ATOM_PINS_STOP_WHEN_UNNEEDED | UNIT_ATOM_ADD_CANNOT_BE_ACTIVE_WITHOUT_QUEUE | diff --git a/src/core/unit-dependency-atom.h b/src/core/unit-dependency-atom.h index 96f00ca39a8..89a3eae1bf0 100644 --- a/src/core/unit-dependency-atom.h +++ b/src/core/unit-dependency-atom.h @@ -56,35 +56,33 @@ typedef enum UnitDependencyAtom { /* If our start job succeeded but the unit is inactive then (think: oneshot units), propagate this as * failure to the other unit. */ UNIT_ATOM_PROPAGATE_INACTIVE_START_AS_FAILURE = UINT64_C(1) << 17, - /* When putting together a transaction, propagate JOB_STOP from our unit to the other. */ + /* When putting together a transaction, propagate JOB_STOP/JOB_RESTART from our unit to the other. */ UNIT_ATOM_PROPAGATE_STOP = UINT64_C(1) << 18, /* Like UNIT_ATOM_PROPAGATE_STOP, but enqueues a restart job if there's already a start job (avoids * job type conflict). */ UNIT_ATOM_PROPAGATE_STOP_GRACEFUL = UINT64_C(1) << 19, - /* When putting together a transaction, propagate JOB_RESTART from our unit to the other. */ - UNIT_ATOM_PROPAGATE_RESTART = UINT64_C(1) << 20, /* Add the other unit to the default target dependency queue */ - UNIT_ATOM_ADD_DEFAULT_TARGET_DEPENDENCY_QUEUE = UINT64_C(1) << 21, + UNIT_ATOM_ADD_DEFAULT_TARGET_DEPENDENCY_QUEUE = UINT64_C(1) << 20, /* Recheck default target deps on other units (which are target units) */ - UNIT_ATOM_DEFAULT_TARGET_DEPENDENCIES = UINT64_C(1) << 22, + UNIT_ATOM_DEFAULT_TARGET_DEPENDENCIES = UINT64_C(1) << 21, /* The remaining atoms map 1:1 to the equally named high-level deps */ - UNIT_ATOM_ON_FAILURE = UINT64_C(1) << 23, - UNIT_ATOM_ON_SUCCESS = UINT64_C(1) << 24, - UNIT_ATOM_ON_FAILURE_OF = UINT64_C(1) << 25, - UNIT_ATOM_ON_SUCCESS_OF = UINT64_C(1) << 26, - UNIT_ATOM_BEFORE = UINT64_C(1) << 27, - UNIT_ATOM_AFTER = UINT64_C(1) << 28, - UNIT_ATOM_TRIGGERS = UINT64_C(1) << 29, - UNIT_ATOM_TRIGGERED_BY = UINT64_C(1) << 30, - UNIT_ATOM_PROPAGATES_RELOAD_TO = UINT64_C(1) << 31, - UNIT_ATOM_JOINS_NAMESPACE_OF = UINT64_C(1) << 32, - UNIT_ATOM_REFERENCES = UINT64_C(1) << 33, - UNIT_ATOM_REFERENCED_BY = UINT64_C(1) << 34, - UNIT_ATOM_IN_SLICE = UINT64_C(1) << 35, - UNIT_ATOM_SLICE_OF = UINT64_C(1) << 36, - _UNIT_DEPENDENCY_ATOM_MAX = (UINT64_C(1) << 37) - 1, + UNIT_ATOM_ON_FAILURE = UINT64_C(1) << 22, + UNIT_ATOM_ON_SUCCESS = UINT64_C(1) << 23, + UNIT_ATOM_ON_FAILURE_OF = UINT64_C(1) << 24, + UNIT_ATOM_ON_SUCCESS_OF = UINT64_C(1) << 25, + UNIT_ATOM_BEFORE = UINT64_C(1) << 26, + UNIT_ATOM_AFTER = UINT64_C(1) << 27, + UNIT_ATOM_TRIGGERS = UINT64_C(1) << 28, + UNIT_ATOM_TRIGGERED_BY = UINT64_C(1) << 29, + UNIT_ATOM_PROPAGATES_RELOAD_TO = UINT64_C(1) << 30, + UNIT_ATOM_JOINS_NAMESPACE_OF = UINT64_C(1) << 31, + UNIT_ATOM_REFERENCES = UINT64_C(1) << 32, + UNIT_ATOM_REFERENCED_BY = UINT64_C(1) << 33, + UNIT_ATOM_IN_SLICE = UINT64_C(1) << 34, + UNIT_ATOM_SLICE_OF = UINT64_C(1) << 35, + _UNIT_DEPENDENCY_ATOM_MAX = (UINT64_C(1) << 36) - 1, _UNIT_DEPENDENCY_ATOM_INVALID = -EINVAL, } UnitDependencyAtom; -- 2.47.3