Support discard in "block" and "swapon"#13
Open
mstorchak wants to merge 4 commits intoopenwrt:masterfrom
Open
Conversation
Author
Define swap flags according to the kernel definitions: musl and glibc provide SWAP_FLAG_DISCARD, but not discard policies. Based on busybox's swaponoff.c Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
Intorduce a new fstab.@swap[] attribute, "discard" that can take values - on, 1, yes -- to enable the default discard mode - once, pages -- to enable the corresponding discard policy - anythinge else -- to disable discard Discard is enabled by default. Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
Add a new option, -d, with an optional argument "once" or "pages". -d with no arguments uses the default kernel discarding policy which enables both the initial discard (once) and discards the released swap pages. By default discard is disabled. Inspired by busybox's swaponoff.c Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
It's safe to enable discard on the devices that don't support it. In such case kernel ignores the discard flags. Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SSD drives are quite common, so following their rules (discarding the unused blocks) can extend their life time. In addition, even if the device doesn't support discard, kernel can always "downgrade" the flags.
This PR adds discard options to
blockby extending theswapentries offstabconfig with thediscardparameter that provides full control over the discard feature.swaponis another entry point for swap activation, so it gets an extra flag-d. The implementation is inspired by busybox.