[PATCH] add discard option -d to swapon
Matt Whitlock
busybox at mattwhitlock.name
Sat Mar 22 23:33:04 UTC 2014
Attached are a series of three patches affecting swaponoff.
Patch #1 fixes two small logic errors: (a) the bb_strtou function was called inside an instantiation of the MIN macro, which would cause the function to be called twice in the common case; and (b) the actual maximum allowable swap priority is SWAP_FLAG_PRIO_MASK >> SWAP_FLAG_PRIO_SHIFT, not simply SWAP_FLAG_PRIO_MASK as the code previously assumed. It just so happens that SWAP_FLAG_PRIO_SHIFT == 0, but one should not rely on that serendipity.
Patch #2 fixes the interaction of the -a and -p options to swapon. When -p is given on the command line, the specified priority should be applied to any swap areas given in /etc/fstab that lack a 'pri' option. This is the way swapon from util-linux does it, and it's the rational behavior, or else -p and -a should be mutually exclusive options.
Patch #3 adds a -d option to swapon, which sets SWAP_FLAG_DISCARD and potentially SWAP_FLAG_DISCARD_ONCE or SWAP_FLAG_DISCARD_PAGES if a policy is given. The patch also adds support for the 'discard' option in swap entries in /etc/fstab.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avoid-calling-bb_strtou-twice-in-MIN-macro-expansion.patch
Type: text/x-patch
Size: 2077 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140322/d7988c4b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-fix-interaction-of-a-and-p-options-in-swapon.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140322/d7988c4b/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-add-discard-option-d-to-swapon.patch
Type: text/x-patch
Size: 5313 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140322/d7988c4b/attachment-0002.bin>
More information about the busybox
mailing list