From c551e3a4aa90daaa85f541136dda66216a2a7d732ece91481598b8b3e3eab284 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 16 Sep 2013 18:44:03 +0000 Subject: [PATCH] Accepting request 199286 from home:elvigia:branches:Base:System - 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch really fixes the swap unit problem mentioned in previous commit & the opensuse-factory mailing list. - 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch really fixes the swap unit problem mentioned in previous commit & the opensuse-factory mailing list. OBS-URL: https://build.opensuse.org/request/show/199286 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=436 --- ...-.wants-symlink-to-auto-swap-devices.patch | 90 +++++++++++++++++++ systemd-mini.changes | 7 ++ systemd-mini.spec | 3 + systemd.changes | 7 ++ systemd.spec | 3 + 5 files changed, 110 insertions(+) create mode 100644 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch diff --git a/0008-swap-create-.wants-symlink-to-auto-swap-devices.patch b/0008-swap-create-.wants-symlink-to-auto-swap-devices.patch new file mode 100644 index 00000000..a81842b9 --- /dev/null +++ b/0008-swap-create-.wants-symlink-to-auto-swap-devices.patch @@ -0,0 +1,90 @@ +From 9981460a8f2d5587fef5216d556b5fb502281be6 Mon Sep 17 00:00:00 2001 +From: Tom Gundersen +Date: Mon, 16 Sep 2013 01:08:32 +0200 +Subject: [PATCH 8/8] swap: create .wants symlink to 'auto' swap devices + +As we load unit files lazily, we need to make sure something pulls in swap +units that should be started automatically, otherwise the default dependencies +will never be applied. + +This partially reinstates code removed in +commit 64347fc2b983f33e7efb0fd2bb44e133fb9f30f4. + +Also don't order swap devices after swap.target when they are 'nofail'. +--- + src/core/swap.c | 8 ++++++-- + src/fstab-generator/fstab-generator.c | 18 ++++++++++++++++-- + 2 files changed, 22 insertions(+), 4 deletions(-) + +diff --git a/src/core/swap.c b/src/core/swap.c +index 3950860..76c7d45 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -220,8 +220,12 @@ static int swap_add_default_dependencies(Swap *s) { + } + + if (!noauto) { +- r = unit_add_two_dependencies_by_name_inverse(UNIT(s), UNIT_AFTER, (nofail ? UNIT_WANTS : UNIT_REQUIRES), +- SPECIAL_SWAP_TARGET, NULL, true); ++ if (nofail) ++ r = unit_add_dependency_by_name_inverse(UNIT(s), ++ UNIT_WANTS, SPECIAL_SWAP_TARGET, NULL, true); ++ else ++ r = unit_add_two_dependencies_by_name_inverse(UNIT(s), ++ UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SWAP_TARGET, NULL, true); + if (r < 0) + return r; + } +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 6ebe8aa..b73dfa4 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -66,6 +66,7 @@ static int mount_find_pri(struct mntent *me, int *ret) { + static int add_swap(const char *what, struct mntent *me) { + _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL, *device = NULL; + _cleanup_fclose_ FILE *f = NULL; ++ bool noauto; + int r, pri = -1; + + assert(what); +@@ -77,6 +78,8 @@ static int add_swap(const char *what, struct mntent *me) { + return pri; + } + ++ noauto = !!hasmntopt(me, "noauto"); ++ + name = unit_name_from_path(what, ".swap"); + if (!name) + return log_oom(); +@@ -97,8 +100,7 @@ static int add_swap(const char *what, struct mntent *me) { + fprintf(f, + "# Automatically generated by systemd-fstab-generator\n\n" + "[Unit]\n" +- "SourcePath=/etc/fstab\n" +- "\n" ++ "SourcePath=/etc/fstab\n\n" + "[Swap]\n" + "What=%s\n", + what); +@@ -114,6 +116,18 @@ static int add_swap(const char *what, struct mntent *me) { + return -errno; + } + ++ if (!noauto) { ++ lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL); ++ if (!lnk) ++ return log_oom(); ++ ++ mkdir_parents_label(lnk, 0755); ++ if (symlink(unit, lnk) < 0) { ++ log_error("Failed to create symlink %s: %m", lnk); ++ return -errno; ++ } ++ } ++ + return 0; + } + +-- +1.8.1.4 + diff --git a/systemd-mini.changes b/systemd-mini.changes index 70468f80..fdbda224 100644 --- a/systemd-mini.changes +++ b/systemd-mini.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Sep 16 17:41:24 UTC 2013 - crrodriguez@opensuse.org + +- 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch + really fixes the swap unit problem mentioned in previous + commit & the opensuse-factory mailing list. + ------------------------------------------------------------------- Sat Sep 14 19:01:24 UTC 2013 - crrodriguez@opensuse.org diff --git a/systemd-mini.spec b/systemd-mini.spec index eb7c8042..791d8bb4 100644 --- a/systemd-mini.spec +++ b/systemd-mini.spec @@ -185,6 +185,8 @@ Patch51: 0004-random-seed-we-should-return-errno-of-failed-loop_wr.patch Patch52: 0005-core-cgroup-first-print-then-free.patch # PATCH-FIX-UPSTREAM 0006-swap-fix-reverse-dependencies.patch -- SWAP does not mount properly Patch53: 0006-swap-fix-reverse-dependencies.patch +# PATCH-FIX-UPSTREAM 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch really fix swap units +Patch54: 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch # udev patches # PATCH-FIX-OPENSUSE 1001-re-enable-by_path-links-for-ata-devices.patch @@ -438,6 +440,7 @@ cp %{SOURCE7} m4/ %patch51 -p1 %patch52 -p1 %patch53 -p1 +%patch54 -p1 # udev patches %patch1001 -p1 diff --git a/systemd.changes b/systemd.changes index 70468f80..fdbda224 100644 --- a/systemd.changes +++ b/systemd.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Sep 16 17:41:24 UTC 2013 - crrodriguez@opensuse.org + +- 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch + really fixes the swap unit problem mentioned in previous + commit & the opensuse-factory mailing list. + ------------------------------------------------------------------- Sat Sep 14 19:01:24 UTC 2013 - crrodriguez@opensuse.org diff --git a/systemd.spec b/systemd.spec index e34e62f7..59482e6c 100644 --- a/systemd.spec +++ b/systemd.spec @@ -180,6 +180,8 @@ Patch51: 0004-random-seed-we-should-return-errno-of-failed-loop_wr.patch Patch52: 0005-core-cgroup-first-print-then-free.patch # PATCH-FIX-UPSTREAM 0006-swap-fix-reverse-dependencies.patch -- SWAP does not mount properly Patch53: 0006-swap-fix-reverse-dependencies.patch +# PATCH-FIX-UPSTREAM 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch really fix swap units +Patch54: 0008-swap-create-.wants-symlink-to-auto-swap-devices.patch # udev patches # PATCH-FIX-OPENSUSE 1001-re-enable-by_path-links-for-ata-devices.patch @@ -433,6 +435,7 @@ cp %{SOURCE7} m4/ %patch51 -p1 %patch52 -p1 %patch53 -p1 +%patch54 -p1 # udev patches %patch1001 -p1