]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/unit.c
core: convert Slice= into a proper dependency (and add a back dependency)
authorLennart Poettering <lennart@poettering.net>
Tue, 13 Apr 2021 16:37:25 +0000 (18:37 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 May 2021 14:03:01 +0000 (16:03 +0200)
commitd219a2b07cc5dc8ffd5010f08561fab2780d8616
tree5f805afabd4d1434ebf1dc38390870160001d3ef
parent12f64221b0af5a9380a840ebeb897c2cd6cff955
core: convert Slice= into a proper dependency (and add a back dependency)

The slice a unit is assigned to is currently a UnitRef reference. Let's
turn it into a proper dependency, to simplify and clean up code a bit.
Now that new dep types are cheaper, deps should generally be preferable
over everything else, if the concept applies.

This brings one major benefit: we often have to iterate through all unit
a slice contains. So far we iterated through all Before= dependencies of
the slice unit to achieve that, filtering out unrelated units, and
taking benefit of the fact that slice units are implicitly ordered
Before= the units they contain. By making Slice= a proper dependency,
and having an accompanying SliceOf= dependency type, this is much
simpler and nicer as we can directly enumerate the units a slice
contains.

The forward dependency is actually called InSlice internally, since we
already used the UNIT_SLICE name as UnitType field. However, since we
don't intend to expose the dependency to users as dep anyway (we already
have the regular Slice D-Bus property for this) this shouldn't matter.
The SliceOf= implicit dependency type (the erverse of Slice=/InSlice=)
is exported over the bus, to make things a bit nicer to debug and
discoverable.
man/org.freedesktop.systemd1.xml
src/basic/unit-def.c
src/basic/unit-def.h
src/core/cgroup.c
src/core/dbus-unit.c
src/core/load-fragment.c
src/core/slice.c
src/core/unit-dependency-atom.c
src/core/unit-dependency-atom.h
src/core/unit.c
src/core/unit.h