diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-01-21 18:19:08 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-01-21 20:23:44 +0100 |
commit | 44b0d1fd597d7034a995feb385b41a6820f4aac0 (patch) | |
tree | 43033103fc19ac8bb827e3ba9d0c289b48fea17a /src/core/swap.c | |
parent | e3e6f996894f0eea0e766b4194922f5c7235fb01 (diff) | |
download | systemd-44b0d1fd597d7034a995feb385b41a6820f4aac0.tar.gz |
core: add implicit ordering dep on blockdev@.target from all mount units
This way we shuld be able to order mounts properly against their backing
services in case complex storage is used (i.e. LUKS), even if the device
path used for mounting the devices is different from the expected device
node of the backing service.
Specifically, if we have a LUKS device /dev/mapper/foo that is mounted
by this name all is trivial as the relationship can be established a
priori easily. But if it is mounted via a /dev/disk/by-uuid/ symlink or
similar we only can relate the device node generated to the one mounted
at the moment the device is actually established. That's because the
UUID of the fs is stored inside the encrypted volume and thus not
knowable until the volume is set up. This patch tries to improve on this
situation: a implicit After=blockdev@.target dependency is generated for
all mounts, based on the data from /proc/self/mountinfo, which should be
the actual device node, with all symlinks resolved. This means that as
soon as the mount is established the ordering via blockdev@.target will
work, and that means during shutdown it is honoured, which is what we
are looking for.
Note that specifying /etc/fstab entries via UUID= for LUKS devices still
sucks and shouldn't be done, because it means we cannot know which LUKS
device to activate to make an fs appear, and that means unless the
volume is set up at boot anyway we can't really handle things
automatically when putting together transactions that need the mount.
Diffstat (limited to 'src/core/swap.c')
-rw-r--r-- | src/core/swap.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/swap.c b/src/core/swap.c index 713d785618..fd2fa557db 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -199,6 +199,7 @@ static SwapParameters* swap_get_parameters(Swap *s) { static int swap_add_device_dependencies(Swap *s) { UnitDependencyMask mask; SwapParameters *p; + int r; assert(s); @@ -211,8 +212,13 @@ static int swap_add_device_dependencies(Swap *s) { mask = s->from_proc_swaps ? UNIT_DEPENDENCY_PROC_SWAP : UNIT_DEPENDENCY_FILE; - if (is_device_path(p->what)) - return unit_add_node_dependency(UNIT(s), p->what, UNIT_REQUIRES, mask); + if (is_device_path(p->what)) { + r = unit_add_node_dependency(UNIT(s), p->what, UNIT_REQUIRES, mask); + if (r < 0) + return r; + + return unit_add_blockdev_dependency(UNIT(s), p->what, mask); + } /* File based swap devices need to be ordered after systemd-remount-fs.service, since they might need * a writable file system. */ |