From ce94130e61b9c460474d9a4584381efdd32f2cfa Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 9 Apr 2024 10:08:57 +0800 Subject: [PATCH] ext4: Enable DISCARD by default It improves the performance and lifespan of some storages by enabling the operating system to inform the drive when data blocks are no longer in use, allowing for more efficient garbage collection and wear leveling. To disable it, use the nodiscard mount option. Change-Id: I215ca87c00f32908c1ae233bc9304e7b647f60ea Signed-off-by: Jeffy Chen --- fs/ext4/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 601e097e1720..83968f06673b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4331,7 +4331,9 @@ static void ext4_set_def_opts(struct super_block *sb, set_opt(sb, ERRORS_RO); /* block_validity enabled by default; disable with noblock_validity */ set_opt(sb, BLOCK_VALIDITY); - if (def_mount_opts & EXT4_DEFM_DISCARD) + /* discard enabled by default for Rockchip; disable with nodiscard */ + if (IS_ENABLED(CONFIG_ARCH_ROCKCHIP) || + (def_mount_opts & EXT4_DEFM_DISCARD)) set_opt(sb, DISCARD); if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0)