summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-28 20:35:50 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-07 17:35:32 +0100
commit06721f39f6adcfd8319ffb3d79ece87b8ef38506 (patch)
treecd23e820a8b072e1c9bc93ce6cdeabf25fb0a30a /src/core
parenta0a424083f4612bdddedb8680a9b05fc86c14b40 (diff)
downloadsystemd-06721f39f6adcfd8319ffb3d79ece87b8ef38506.tar.gz
swap: always add in extras when we load a swap unit
Much like for the mount units we need fields such as the slice initialized by the time we activate the swap, hence when the kernel let's us know about a new swap that appeared we need to initialize the slice in any Swap object we allocated for that right-away, even if we can't read the real unit file for the swap device.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/swap.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/swap.c b/src/core/swap.c
index 277d0791c2..2d8463b8b1 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -337,7 +337,7 @@ static int swap_add_extras(Swap *s) {
static int swap_load(Unit *u) {
Swap *s = SWAP(u);
- int r;
+ int r, q;
assert(s);
assert(u->load_state == UNIT_STUB);
@@ -347,16 +347,18 @@ static int swap_load(Unit *u) {
r = unit_load_fragment_and_dropin_optional(u);
else
r = unit_load_fragment_and_dropin(u);
- if (r < 0)
- return r;
- if (u->load_state == UNIT_LOADED) {
-
- r = swap_add_extras(s);
- if (r < 0)
- return r;
+ /* Add in some extras, and do so either when we successfully loaded something or when /proc/swaps is already
+ * active. */
+ if (u->load_state == UNIT_LOADED || s->from_proc_swaps)
+ q = swap_add_extras(s);
+ else
+ q = 0;
- }
+ if (r < 0)
+ return r;
+ if (q < 0)
+ return q;
return swap_verify(s);
}