aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorShaohua Li <shli@kernel.org>2012-03-21 16:34:17 -0700
committerBen Hutchings <ben@decadent.org.uk>2012-05-31 00:43:47 +0100
commit07fb30fa5b317e65a6953471886b7fd04e1acb51 (patch)
tree9da224d88791c3600b03aecc57fe2cd891602dd4 /mm/swapfile.c
parentff741084d380bd234a4d0ffba0c19e8047a14658 (diff)
downloadkernel_samsung_smdk4412-07fb30fa5b317e65a6953471886b7fd04e1acb51.zip
kernel_samsung_smdk4412-07fb30fa5b317e65a6953471886b7fd04e1acb51.tar.gz
kernel_samsung_smdk4412-07fb30fa5b317e65a6953471886b7fd04e1acb51.tar.bz2
swap: don't do discard if no discard option added
commit 052b1987faca3606109d88d96bce124851f7c4c2 upstream. When swapon() was not passed the SWAP_FLAG_DISCARD option, sys_swapon() will still perform a discard operation. This can cause problems if discard is slow or buggy. Reverse the order of the check so that a discard operation is performed only if the sys_swapon() caller is attempting to enable discard. Signed-off-by: Shaohua Li <shli@fusionio.com> Reported-by: Holger Kiehl <Holger.Kiehl@dwd.de> Tested-by: Holger Kiehl <Holger.Kiehl@dwd.de> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 2015a1e..d3955f2 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2102,7 +2102,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
p->flags |= SWP_SOLIDSTATE;
p->cluster_next = 1 + (random32() % p->highest_bit);
}
- if (discard_swap(p) == 0 && (swap_flags & SWAP_FLAG_DISCARD))
+ if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0)
p->flags |= SWP_DISCARDABLE;
}