swap: don't do discard if no discard option added
authorShaohua Li <[email protected]>
Wed, 21 Mar 2012 23:34:17 +0000 (16:34 -0700)
committerLinus Torvalds <[email protected]>
Thu, 22 Mar 2012 00:55:00 +0000 (17:55 -0700)
commit052b1987faca3606109d88d96bce124851f7c4c2
tree879df883edb01ea6e0da880e391b06bb69058129
parent1480de0340a8d5f094b74d7c4b902456c9a06903
swap: don't do discard if no discard option added

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 <[email protected]>
Reported-by: Holger Kiehl <[email protected]>
Tested-by: Holger Kiehl <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/swapfile.c