]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
units: add ordering dependencies on initrd-switch-root.target
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 14 Sep 2022 11:39:10 +0000 (12:39 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Sep 2022 12:59:11 +0000 (14:59 +0200)
For shutdown, we queue shutdown.target/start, so in every unit which should be
stopped *before* shutdown, we need both Conflicts and an ordering dependency
with shutdown.target (either Before= or After= would work, because stop jobs
are always ordered before start jobs).

For initrd transition, we queue initrd-switch-root.service/isolate. This
automatically creates a /stop job for every running unit without
IgnoreOnIsolate. But no ordering dependency is created, unless the unit has a
(possibly transitive) ordering dependency on initrd-switch-root.service.
Since most units must stop before the transition, we should add the ordering
dependency. It is nicer to use Before=initrd-switch-root.target for this.
initrd-switch-root.target is ordered before initrd-switch-root.service, so
the effect it the same when both are in a transaction.

Fixes #23745.

To also cover the case where somebody is emergency mode in the initrd and
queues initrd-switch-root.service/start (not isolate), also add
Conflicts=initrd-switch-root.target, so various units are stopped properly.
This extends 2525682565b372b9b83c848bfe89c025fed47a1d to cover all the other
services that are touched. It could be consider "operator error", but it's
easy to make and it's nicer if we can make this more foolproof.

units/ldconfig.service
units/systemd-ask-password-console.service
units/systemd-boot-system-token.service
units/systemd-network-generator.service.in
units/systemd-sysext.service
units/systemd-sysusers.service
units/systemd-tmpfiles-clean.service
units/systemd-tmpfiles-setup-dev.service
units/systemd-tmpfiles-setup.service

index cb887ae8659de51195bc775811b76b92dc1af6ee..53c6d4ecb16c92d9f5775832103f10746de58876 100644 (file)
@@ -17,8 +17,8 @@ ConditionFileNotEmpty=|!/etc/ld.so.cache
 DefaultDependencies=no
 After=local-fs.target
 Before=sysinit.target systemd-update-done.service
-Conflicts=shutdown.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 [Service]
 Type=oneshot
index 97c651f0090082c25f416c62f6f1c0c76fa5921f..9360bf1d5abc19cfabc422ef0a25a4ba30ec79c1 100644 (file)
@@ -16,8 +16,8 @@ ConditionPathExists=!/run/plymouth/pid
 DefaultDependencies=no
 After=plymouth-start.service systemd-vconsole-setup.service
 Conflicts=emergency.service
-Conflicts=shutdown.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 [Service]
 ExecStart=systemd-tty-ask-password-agent --watch --console
index 56d3c8ad471a314d547a4c55b45be3e65adb6054..662a1fda04ba4fcf7c77acc99da5852181f737c6 100644 (file)
@@ -12,9 +12,9 @@ Description=Store a System Token in an EFI Variable
 Documentation=man:systemd-boot-system-token.service(8)
 
 DefaultDependencies=no
-Conflicts=shutdown.target
 After=local-fs.target systemd-random-seed.service
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 # Don't run this in a VM environment, because there EFI variables are not
 # actually stored in NVRAM, independent of regular storage.
index 41c27c50d89ced36dac273cbb6c0b81c3cb7f798..2b79ca6b8a898b29711d5b3b1979cfa72f25baee 100644 (file)
@@ -14,8 +14,8 @@ Documentation=man:systemd-network-generator.service(8)
 DefaultDependencies=no
 Before=network-pre.target systemd-udevd.service
 Wants=network-pre.target
-Conflicts=shutdown.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 [Service]
 Type=oneshot
index 245c0e5a0d41648513e0e9832c821907a98cf404..254de2b623b35c3ae9fcf154be72eec0f9513a6a 100644 (file)
@@ -21,8 +21,8 @@ ConditionDirectoryNotEmpty=|/usr/lib/extensions
 DefaultDependencies=no
 After=local-fs.target
 Before=sysinit.target systemd-tmpfiles.service
-Conflicts=shutdown.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 [Service]
 Type=oneshot
index 8b9335ff28ac7037dd6ce27125e368d31406e1c1..0eb40294b2123b668e9ee68e956f13b19671ed7b 100644 (file)
@@ -14,8 +14,8 @@ Documentation=man:sysusers.d(5) man:systemd-sysusers.service(8)
 DefaultDependencies=no
 After=systemd-remount-fs.service
 Before=sysinit.target systemd-update-done.service
-Conflicts=shutdown.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 ConditionNeedsUpdate=|/etc
 ConditionCredential=|sysusers.extra
index 7f1b7ec594e8d8528abe7bde101a42eb2101818a..4163aef729b75a12633f70cc10246b2609877cb0 100644 (file)
@@ -12,9 +12,9 @@ Description=Cleanup of Temporary Directories
 Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
 
 DefaultDependencies=no
-Conflicts=shutdown.target initrd-switch-root.service
 After=local-fs.target time-set.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 [Service]
 Type=oneshot
index d202a7568f356ae96c762be468bbd478ec3b5786..c65539aa79770104143506dc0de014b73b58e186 100644 (file)
@@ -14,8 +14,8 @@ Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
 DefaultDependencies=no
 After=systemd-sysusers.service
 Before=sysinit.target local-fs-pre.target systemd-udevd.service
-Conflicts=shutdown.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 
 [Service]
 Type=oneshot
index baed27df7589146ca6a443b6edb6638b481cfdcd..7e11eb941445ab539a38212fb3ea2d317c23bd27 100644 (file)
@@ -12,10 +12,10 @@ Description=Create Volatile Files and Directories
 Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
 
 DefaultDependencies=no
-Conflicts=shutdown.target initrd-switch-root.service
 After=local-fs.target systemd-sysusers.service systemd-journald.service
 Before=sysinit.target
-Before=shutdown.target
+Conflicts=shutdown.target initrd-switch-root.target
+Before=shutdown.target initrd-switch-root.target
 RefuseManualStop=yes
 
 [Service]