From c4793975137d5d522fee104b7dab94a79547effd Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 24 Nov 2015 03:17:39 +0100 Subject: [PATCH] Make sure all swap units are ordered before the swap target This avoids that swap devices are being stopped prematurely during shutdown. Closes: #805133 --- debian/changelog | 6 +++ ...its-are-ordered-before-the-swap-targ.patch | 45 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 52 insertions(+) create mode 100644 debian/patches/make-sure-all-swap-units-are-ordered-before-the-swap-targ.patch diff --git a/debian/changelog b/debian/changelog index 945b24994..cf5ab9e7c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,13 @@ systemd (215-17+deb8u4) UNRELEASED; urgency=medium + [ Martin Pitt ] * debian/udev.prerm: Add missing "deconfigure" action. (Closes: #809744) + [ Michael Biebl ] + * Make sure all swap units are ordered before the swap target. This avoids + that swap devices are being stopped prematurely during shutdown. + (Closes: #805133) + -- Martin Pitt Sat, 09 Jan 2016 16:24:05 +0100 systemd (215-17+deb8u3) stable; urgency=medium diff --git a/debian/patches/make-sure-all-swap-units-are-ordered-before-the-swap-targ.patch b/debian/patches/make-sure-all-swap-units-are-ordered-before-the-swap-targ.patch new file mode 100644 index 000000000..a3bd75085 --- /dev/null +++ b/debian/patches/make-sure-all-swap-units-are-ordered-before-the-swap-targ.patch @@ -0,0 +1,45 @@ +From: Franck Bui +Date: Mon, 23 Nov 2015 11:14:10 +0100 +Subject: make sure all swap units are ordered before the swap target + +When shutting down the system, the swap devices can be disabled long +time before the swap target is stopped. They're actually the first +units systemd turns off on my system. + +This is incorrect and due to swap devices having multiple associated +swap unit files. The main one is usually created by the fstab +generator and is used to start the swap device. + +Once done, systemd creates some 'alias' units for the same swap +device, one for each swap dev link. But those units are missing an +ordering dependencies which was created by the fstab generator for the +main swap unit. + +Therefore during shutdown those 'alias' units can be stopped at +anytime before unmount.target target. + +This patch makes sure that all swap units are stopped after the +swap.target target. + +(cherry-picked from commit 8bf23dc757dacaaf5a8d2c21aabf71aee08d1a04) +--- + src/core/swap.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/core/swap.c b/src/core/swap.c +index 020cbcb..cddb6b2 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -224,6 +224,12 @@ static int swap_add_default_dependencies(Swap *s) { + if (detect_container(NULL) > 0) + return 0; + ++ /* swap units generated for the swap dev links are missing the ++ * ordering dep against the swap target. */ ++ r = unit_add_dependency_by_name(UNIT(s), UNIT_BEFORE, SPECIAL_SWAP_TARGET, NULL, true); ++ if (r < 0) ++ return r; ++ + r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true); + if (r < 0) + return r; diff --git a/debian/patches/series b/debian/patches/series index c5ca9d257..dcbb4f617 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -156,6 +156,7 @@ cryptsetup-Fix-timeout-on-dm-device.patch core-only-set-the-kernel-s-timezone-when-the-RTC-runs-in-.patch delta-Fix-broken-separator-support.patch sd-dhcp-client-make-request-broadcasts-configurable.patch +make-sure-all-swap-units-are-ordered-before-the-swap-targ.patch ## Debian specific patches: Add-back-support-for-Debian-specific-config-files.patch -- GitLab