|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From cdc8982030271785d650af410230397bbb5a4be9 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: Sun, 28 Sep 2014 10:37:52 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] core/swap: follow the configured unit by default
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Phenomenon: parameters configured in /etc/fstab for swap units are
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
ignored. E.g. pri= settings have no effect when systemd starts swap
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
units. What is even more confusing, .swap units for the name used in
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/etc/fstab initially show proper values for Priority=, but after
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
starting them, they are re-initalized from /proc/swaps and show the -1
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
value from /proc/swaps.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Change swap units to follow the original configured unit. This way
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
proper settings are used when starting the swap.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/swap.c | 21 ++++++++++++++++++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 18 insertions(+), 3 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 36c9e029e9..ef90d0efde 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 |
@@ -1208,11 +1208,25 @@ static Unit *swap_following(Unit *u) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (streq_ptr(s->what, s->devnode))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* If the user configured the swap through /etc/fstab or
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * a device unit, follow that. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (s->from_fragment)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- /* Make everybody follow the unit that's named after the swap
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * device in the kernel */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ LIST_FOREACH_AFTER(same_devnode, other, s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (other->from_fragment)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return UNIT(other);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ LIST_FOREACH_BEFORE(same_devnode, other, s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (other->from_fragment)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return UNIT(other);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* Otherwise make everybody follow the unit that's named after
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * the swap device in the kernel */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (streq_ptr(s->what, s->devnode))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
LIST_FOREACH_AFTER(same_devnode, other, s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (streq_ptr(other->what, other->devnode))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1225,6 +1239,7 @@ static Unit *swap_following(Unit *u) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
first = other;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* Fall back to the first on the list */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return UNIT(first);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|