Skip to content

Commit 5f1cf94

Browse files
Diangang Litytso
authored andcommitted
ext4: clear DISCARD flag if device does not support discard
commit 79add3a ("ext4: notify when discard is not supported") noted that keeping the DISCARD flag is for possibility that the underlying device might change in future even without file system remount. However, this scenario has rarely occurred in practice on the device side. Even if it does occur, it can be resolved with remount. Clearing the DISCARD flag not only prevents confusion caused by mount options but also avoids sending unnecessary discard commands. Signed-off-by: Diangang Li <lidiangang@bytedance.com> Link: https://patch.msgid.link/20250311021310.669524-1-lidiangang@bytedance.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 7437176 commit 5f1cf94

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/ext4/super.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5620,9 +5620,11 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
56205620
goto failed_mount9;
56215621
}
56225622

5623-
if (test_opt(sb, DISCARD) && !bdev_max_discard_sectors(sb->s_bdev))
5623+
if (test_opt(sb, DISCARD) && !bdev_max_discard_sectors(sb->s_bdev)) {
56245624
ext4_msg(sb, KERN_WARNING,
56255625
"mounting with \"discard\" option, but the device does not support discard");
5626+
clear_opt(sb, DISCARD);
5627+
}
56265628

56275629
if (es->s_error_count)
56285630
mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */

0 commit comments

Comments
 (0)