|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 3018d31238caabc2e204aa161e647dc1c1b5d1c6 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Thu, 2 Oct 2014 00:11:36 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] core/swap: only make configured units part of swap.target
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
We used to make all .swap units either RequiredBy=swap.target or
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
WantedBy=swap.target. But swap.target should be the "configured swap
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
units", either through /etc/fstab or non-generated .swap units. It
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
is surprising when systemd starts treating a swap device that was
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
possibly temporarily enabled as a hard dependency for other units.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
So do not add dependencies with swap.target for units gleaned from
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/proc/swaps.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Similarly, we added dependencies for all aliases of the device name,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
which clutters up the dependency graph but does not seem to bring any
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
value, since the status of those following units is consistent with
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
the main one anyway.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
This should be a fix for [1], and it seems the right thing to do
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
anyway.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1114786
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/swap.c | 20 +++++++++++---------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/swap.c b/src/core/swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index ef90d0efde..b2ca048bcb 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -213,7 +213,7 @@ static int swap_add_device_links(Swap *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int swap_add_default_dependencies(Swap *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- bool nofail = false, noauto = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ bool nofail, noauto;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -228,23 +228,25 @@ static int swap_add_default_dependencies(Swap *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (s->from_fragment) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- SwapParameters *p = &s->parameters_fragment;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!s->from_fragment)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* The swap unit can either be for an alternative device name, in which
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * case we don't need to add the dependency on swap.target because this unit
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * is following a different unit which will have this dependency added,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * or it can be derived from /proc/swaps, in which case it was started
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * manually, and should not become a dependency of swap.target. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- nofail = p->nofail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- noauto = p->noauto;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ nofail = s->parameters_fragment.nofail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ noauto = s->parameters_fragment.noauto;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!noauto) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (nofail)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = unit_add_dependency_by_name_inverse(UNIT(s), UNIT_WANTS, SPECIAL_SWAP_TARGET, NULL, true);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = unit_add_two_dependencies_by_name_inverse(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SWAP_TARGET, NULL, true);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return r < 0 ? r : 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int swap_verify(Swap *s) {
|