forked from pool/systemd
34 lines
1.4 KiB
Diff
34 lines
1.4 KiB
Diff
|
From b61e88162a6ce0c30da6984b0120959701283daa Mon Sep 17 00:00:00 2001
|
||
|
From: Olivier Brunel <i.am.jack.mail@gmail.com>
|
||
|
Date: Sat, 13 Oct 2012 14:24:15 +0200
|
||
|
Subject: [PATCH] swap: fix swap behaviour with symlinks
|
||
|
|
||
|
Starting a swap unit pointing to (What) a symlink (e.g. /dev/mapper/swap
|
||
|
or /dev/disk/by-uuid/...) would have said unit marked active, following
|
||
|
the one using the "actual" device (/dev/{dm-1,sda3}), but that new unit
|
||
|
would be seen as inactive.
|
||
|
Since all requests to stop swap units would follow/redirect to it,
|
||
|
and it is seen inactive, nothing would be done (swapoff never called).
|
||
|
|
||
|
This is because this unit would be treated twice in
|
||
|
swap_process_new_swap, the second call to swap_add_one causing it to
|
||
|
eventually be marked inactive.
|
||
|
---
|
||
|
src/core/swap.c | 3 ++-
|
||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||
|
|
||
|
Index: systemd-195/src/core/swap.c
|
||
|
===================================================================
|
||
|
--- systemd-195.orig/src/core/swap.c
|
||
|
+++ systemd-195/src/core/swap.c
|
||
|
@@ -415,7 +415,8 @@ static int swap_process_new_swap(Manager
|
||
|
return -ENOMEM;
|
||
|
|
||
|
dn = udev_device_get_devnode(d);
|
||
|
- if (dn)
|
||
|
+ /* Skip dn==device, since that case will be handled below */
|
||
|
+ if (dn && !streq(dn, device))
|
||
|
r = swap_add_one(m, dn, device, prio, false, false, set_flags);
|
||
|
|
||
|
/* Add additional units for all symlinks */
|