1
0
mirror of https://github.com/systemd/systemd synced 2026-03-31 12:14:57 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Mike Yuan
d22139ad71 user-record: use clzll() instead of clzl() for uint64_t 2025-11-18 09:49:01 +09:00
Yu Watanabe
031963fb16
core/unit: unit_process_job() tweaks (#39753) 2025-11-18 08:32:59 +09:00
Mike Yuan
bcf95c4116 labeler: match the whole tree of shell-completion/ 2025-11-18 08:26:16 +09:00
Mike Yuan
aea6c4b53f
core/unit: modernize unit_process_job() a bit
* Inline one condition
* Annotate boolean args with names
2025-11-17 19:30:00 +01:00
Mike Yuan
2334953a49
core/unit: always propagate reload_result as job result, even if state is unexpected
The end state of unit shouldn't have any impact on reload job, as
either way the reload operation has been aborted.
2025-11-17 19:26:11 +01:00
Mike Yuan
a5b1a79461
core/unit: mark running reload job as canceled if the unit deactivated
The semantics of reload is that the service updates its extrinsic state
and continues execution. If it actually deactivated we shouldn't
spuriously notify the caller that reload succeeded.
2025-11-17 19:26:11 +01:00
Mike Yuan
7cb0030f6c
core/unit: no need to handle intermediate job types in unit_process_job()
Installed jobs are always collapsed, i.e. can only be of types
accepted by job_run_and_invalidate() modulo JOB_NOP which is
stored in Unit.nop_job (if any). Let's trim the unreachable
branches.
2025-11-17 19:25:41 +01:00
3 changed files with 10 additions and 21 deletions

2
.github/labeler.yml vendored
View File

@ -228,7 +228,7 @@ selinux:
- any-glob-to-any-file: '**/*selinux*' - any-glob-to-any-file: '**/*selinux*'
shell-completion: shell-completion:
- changed-files: - changed-files:
- any-glob-to-any-file: 'shell-completion/*' - any-glob-to-any-file: 'shell-completion/**'
shell profile: shell profile:
- changed-files: - changed-files:
- any-glob-to-any-file: 'profile.d/*' - any-glob-to-any-file: 'profile.d/*'

View File

@ -2607,9 +2607,9 @@ static void unit_emit_audit_stop(Unit *u, UnitActiveState state) {
static bool unit_process_job(Job *j, UnitActiveState ns, bool reload_success) { static bool unit_process_job(Job *j, UnitActiveState ns, bool reload_success) {
bool unexpected = false; bool unexpected = false;
JobResult result;
assert(j); assert(j);
assert(j->installed);
if (j->state == JOB_WAITING) if (j->state == JOB_WAITING)
/* So we reached a different state for this job. Let's see if we can run it now if it failed previously /* So we reached a different state for this job. Let's see if we can run it now if it failed previously
@ -2625,34 +2625,24 @@ static bool unit_process_job(Job *j, UnitActiveState ns, bool reload_success) {
case JOB_VERIFY_ACTIVE: case JOB_VERIFY_ACTIVE:
if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) if (UNIT_IS_ACTIVE_OR_RELOADING(ns))
job_finish_and_invalidate(j, JOB_DONE, true, false); job_finish_and_invalidate(j, JOB_DONE, /* recursive = */ true, /* already = */ false);
else if (j->state == JOB_RUNNING && ns != UNIT_ACTIVATING) { else if (j->state == JOB_RUNNING && ns != UNIT_ACTIVATING) {
unexpected = true; unexpected = true;
if (UNIT_IS_INACTIVE_OR_FAILED(ns)) { if (UNIT_IS_INACTIVE_OR_FAILED(ns))
if (ns == UNIT_FAILED) job_finish_and_invalidate(j, ns == UNIT_FAILED ? JOB_FAILED : JOB_DONE, /* recursive = */ true, /* already = */ false);
result = JOB_FAILED;
else
result = JOB_DONE;
job_finish_and_invalidate(j, result, true, false);
}
} }
break; break;
case JOB_RELOAD: case JOB_RELOAD:
case JOB_RELOAD_OR_START:
case JOB_TRY_RELOAD:
if (j->state == JOB_RUNNING) { if (j->state == JOB_RUNNING) {
if (ns == UNIT_ACTIVE) if (ns == UNIT_ACTIVE)
job_finish_and_invalidate(j, reload_success ? JOB_DONE : JOB_FAILED, true, false); job_finish_and_invalidate(j, reload_success ? JOB_DONE : JOB_FAILED, /* recursive = */ true, /* already = */ false);
else if (!IN_SET(ns, UNIT_ACTIVATING, UNIT_RELOADING, UNIT_REFRESHING)) { else if (!IN_SET(ns, UNIT_ACTIVATING, UNIT_RELOADING, UNIT_REFRESHING)) {
unexpected = true; unexpected = true;
job_finish_and_invalidate(j, reload_success ? JOB_CANCELED : JOB_FAILED, /* recursive = */ true, /* already = */ false);
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
job_finish_and_invalidate(j, ns == UNIT_FAILED ? JOB_FAILED : JOB_DONE, true, false);
} }
} }
@ -2660,13 +2650,12 @@ static bool unit_process_job(Job *j, UnitActiveState ns, bool reload_success) {
case JOB_STOP: case JOB_STOP:
case JOB_RESTART: case JOB_RESTART:
case JOB_TRY_RESTART:
if (UNIT_IS_INACTIVE_OR_FAILED(ns)) if (UNIT_IS_INACTIVE_OR_FAILED(ns))
job_finish_and_invalidate(j, JOB_DONE, true, false); job_finish_and_invalidate(j, JOB_DONE, /* recursive = */ true, /* already = */ false);
else if (j->state == JOB_RUNNING && ns != UNIT_DEACTIVATING) { else if (j->state == JOB_RUNNING && ns != UNIT_DEACTIVATING) {
unexpected = true; unexpected = true;
job_finish_and_invalidate(j, JOB_FAILED, true, false); job_finish_and_invalidate(j, JOB_FAILED, /* recursive = */ true, /* already = */ false);
} }
break; break;

View File

@ -2041,7 +2041,7 @@ uint64_t user_record_luks_sector_size(UserRecord *h) {
return 512; return 512;
/* Allow up to 4K due to dm-crypt support and 4K alignment by the homed LUKS backend */ /* Allow up to 4K due to dm-crypt support and 4K alignment by the homed LUKS backend */
return CLAMP(UINT64_C(1) << (63 - __builtin_clzl(h->luks_sector_size)), 512U, 4096U); return CLAMP(UINT64_C(1) << (63 - __builtin_clzll(h->luks_sector_size)), 512U, 4096U);
} }
const char* user_record_luks_pbkdf_hash_algorithm(UserRecord *h) { const char* user_record_luks_pbkdf_hash_algorithm(UserRecord *h) {