From d6387c98cb0e0811aafbfdff09256ce2ff7742e4 Mon Sep 17 00:00:00 2001 From: Rafael Aquini Date: Sun, 26 May 2013 01:31:56 -0300 Subject: swapon: allow a more flexible swap discard policy Introduce the necessary changes to swapon(8) allowing a sysadmin to leverage the new changes introduced to sys_swapon by "swap: discard while swapping only if SWAP_FLAG_DISCARD_PAGES", therefore allowing a more flexible set of choices when selection the discard policy for mounted swap areas. This patch introduces the following optional arguments to the already existent swapon(8) "--discard" option, in order to allow a discard type to be selected at swapon time: * once : only single-time area discards are issued. (swapon) * pages : discard freed pages before they are reused. If no policy is selected both discard types are enabled. (default) [kzak@redhat.com: - support argument for short -d option too, - add errx() on unsupported policy name] Signed-off-by: Rafael Aquini Acked-by: KOSAKI Motohiro Signed-off-by: Karel Zak --- sys-utils/swapon.8 | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'sys-utils/swapon.8') diff --git a/sys-utils/swapon.8 b/sys-utils/swapon.8 index 385bf5aea..836b17277 100644 --- a/sys-utils/swapon.8 +++ b/sys-utils/swapon.8 @@ -112,15 +112,25 @@ All devices marked as ``swap'' in are made available, except for those with the ``noauto'' option. Devices that are already being used as swap are silently skipped. .TP -.B "\-d, \-\-discard" -Discard freed swap pages before they are reused, if the swap -device supports the discard or trim operation. This may improve -performance on some Solid State Devices, but often it does not. +.B "\-d, \-\-discard\fR [=\fIpolicy\fR]" +Enable swap discards, if the swap backing device supports the discard or +trim operation. This may improve performance on some Solid State Devices, +but often it does not. The option allows one to select between two +available swap discard policies: +.BI \-\-discard=once +to perform a single-time discard operation for the whole swap area at swapon; +or +.BI \-\-discard=pages +to discard freed swap pages before they are reused, while swapping. +If no policy is selected, the default behavior is to enable both discard types. The .I /etc/fstab -mount option -.BI discard -may be also used to enable discard flag. +mount options +.BI discard, +.BI discard=once, +or +.BI discard=pages +may be also used to enable discard flags. .TP .B "\-e, \-\-ifexists" Silently skip devices that do not exist. -- cgit v1.2.3-55-g7522