swapon: adhere swap priority in fstab
authorDennis Groenen <tj.groenen@gmail.com>
Sun, 4 Aug 2013 12:04:39 +0000 (14:04 +0200)
committerDennis Groenen <tj.groenen@gmail.com>
Sun, 4 Aug 2013 12:04:39 +0000 (14:04 +0200)
debian/patches/0001-swapon-adhere-swap-priority-in-fstab.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/0001-swapon-adhere-swap-priority-in-fstab.patch b/debian/patches/0001-swapon-adhere-swap-priority-in-fstab.patch
new file mode 100644 (file)
index 0000000..74d874f
--- /dev/null
@@ -0,0 +1,62 @@
+From 568f3f41b734f410dcd1913e25b57dde17959233 Mon Sep 17 00:00:00 2001
+From: Dennis Groenen <tj.groenen@gmail.com>
+Date: Sun, 4 Aug 2013 14:00:59 +0200
+Subject: [PATCH] swapon: adhere swap priority in fstab
+
+We already had the mount opts from fstab, but didn't do anything with them.
+
+Check mnt_opts and set g_flags accordingly prior to enabling the swapspace when
+we do_em_all().
+
+Signed-off-by: Dennis Groenen <tj.groenen at gmail.com>
+---
+ util-linux/Config.src  |    5 +++--
+ util-linux/swaponoff.c |   13 +++++++++++++
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/util-linux/Config.src b/util-linux/Config.src
+index 5a8b006..b90873d 100644
+--- a/util-linux/Config.src
++++ b/util-linux/Config.src
+@@ -600,11 +600,12 @@ config SWAPONOFF
+         option disabled.
+ config FEATURE_SWAPON_PRI
+-      bool "Support priority option -p"
++      bool "Support priority options"
+       default y
+       depends on SWAPONOFF
+       help
+-        Enable support for setting swap device priority in swapon.
++        Enable support for setting swap device priority in swapon. Also makes
++        swapon respect 'pri=n' when enabling all swaps from /etc/fstab.
+ config SWITCH_ROOT
+       bool "switch_root"
+diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
+index 54867ec..97f668e 100644
+--- a/util-linux/swaponoff.c
++++ b/util-linux/swaponoff.c
+@@ -95,6 +95,19 @@ static int do_em_all(void)
+                       if (applet_name[5] != 'n'
+                        || hasmntopt(m, MNTOPT_NOAUTO) == NULL
+                       ) {
++#if ENABLE_FEATURE_SWAPON_PRI /* from util-linux-ng 2.17.2 */
++                              char *opt, *opts;
++
++                              g_flags = 0; /* each swap space might have different flags */
++                              opts = strdup(m->mnt_opts);
++                              for (opt = strtok(opts, ","); opt != NULL;
++                                       opt = strtok(NULL, ",")) {
++                                      if (strncmp(opt, "pri=", 4) == 0)
++                                              g_flags = SWAP_FLAG_PREFER |
++                                                      ((atoi(opt+4) & SWAP_FLAG_PRIO_MASK) << SWAP_FLAG_PRIO_SHIFT);
++                              }
++                              if (ENABLE_FEATURE_CLEAN_UP) free(opts);
++#endif
+                               err += swap_enable_disable(m->mnt_fsname);
+                       }
+               }
+-- 
+1.7.9.5
+
index 735cc69..d8fe04d 100644 (file)
@@ -22,6 +22,7 @@ ps-accept-and-ignore-missing-options.patch
 showkey-default-option.patch
 0001-pgrep-check-whether-we-re-pkill-at-runtime.patch
 0002-ash-install-SIGHUP-signal-handler-when-interactive.patch
+0001-swapon-adhere-swap-priority-in-fstab.patch
 
 # Hotfixes