[fstools, 4/4] fstools: block: enable discard in swapon -a

m.storchak at gmail.com m.storchak at gmail.com
Wed Jul 23 06:19:19 PDT 2025


From: Maxim Storchak <m.storchak at 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 at gmail.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 0d9129b..37ff809 100644
--- a/block.c
+++ b/block.c
@@ -1883,7 +1883,7 @@ static int main_swapon(int argc, char **argv)
 			list_for_each_entry(pr, &devices, list) {
 				if (strcmp(pr->type, "swap"))
 					continue;
-				if (swapon(pr->dev, 0))
+				if (swapon(pr->dev, SWAP_FLAG_DISCARD))
 					ULOG_ERR("failed to swapon %s\n", pr->dev);
 			}
 			return 0;
-- 
2.50.0




More information about the openwrt-devel mailing list