ext4: don't report EOPNOTSUPP errors from discard

When ext4 is mounted without journal, with discard mount option, and on
a device not supporting trim, we print error for each and every freed
extent. This is not only useless but actively harmful. Instead ignore
the EOPNOTSUPP error. Trim is only advisory anyway and when the
filesystem has journal we silently ignore trim error as well.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://lore.kernel.org/r/20240213101601.17463-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Jan Kara 2024-02-13 11:16:01 +01:00 committed by Theodore Ts'o
parent 7f48212678
commit fa60629380

View File

@ -6496,7 +6496,13 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode,
if (test_opt(sb, DISCARD)) {
err = ext4_issue_discard(sb, block_group, bit,
count_clusters, NULL);
if (err && err != -EOPNOTSUPP)
/*
* Ignore EOPNOTSUPP error. This is consistent with
* what happens when using journal.
*/
if (err == -EOPNOTSUPP)
err = 0;
if (err)
ext4_msg(sb, KERN_WARNING, "discard request in"
" group:%u block:%d count:%lu failed"
" with %d", block_group, bit, count,