Re: [PATCH] f2fs: skip further SIT updates for already invalidated blocks

From: Chao Yu

Date: Fri Nov 13 2026 - 07:07:17 EST


Hi Seongjae,

On 11/12/26 18:36, Seongjae Jeong wrote:
I don't see how commit a66cdd985532 ("f2fs: introduce discard_map for f2fs_trim_fs")
introduce the bug? from the timeline, at that point there is no error handling in
update_sit_entries() if sit bitmap is inconsistent, right?


Hi Chao,

Commit a66cdd985532 added the following two lines:

if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map))
f2fs_bug_on(sbi, 1);

Previously, we will trigger f2fs_bug_on() and there is no further error handling
at that point, so that we will update SIT_I(sbi)->written_valid_blocks as well
incorrectly, so I don't think this is a bug of a66cdd985532.

Thanks,

+ if (f2fs_test_and_clear_bit(offset, se->discard_map))
+ sbi->discard_blks++;

Even if the cur_valid_map bit was already clear, the added code
could still clear the discard bit and increment discard_blks if the
discard bit was set.

Since my patch skips that update for an already invalidated block,
I thought a66cdd985532 was an appropriate Fixes tag for the discard
bitmap part of the change.

Thanks,
Seongjae