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 <jeffy.chen@rock-chips.com>
This commit is contained in:
Jeffy Chen
2024-04-09 10:08:57 +08:00
committed by Tao Huang
parent 01f0b83ddf
commit ce94130e61

View File

@@ -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)