Re: [PATCH 1/2] f2fs: simplify node footer check in f2fs_cache_write_end_io

From: Zhiguo Niu

Date: Thu Sep 24 2026 - 04:21:49 EST


Hi Xusheng

Zhan Xusheng <zhanxusheng1024@xxxxxxxxx> 于2026年9月24日周四 15:23写道:
>
> On Thu, Sep 24, 2026 at 09:52:12AM +0800, Zhiguo Niu wrote:
> > - f2fs_bug_on(sbi, entry->index != nid_of_node(sbi, entry));
> > + f2fs_bug_on(sbi, f2fs_sanity_check_node_footer(sbi,
> > + entry, entry->index, NODE_TYPE_REGULAR, true));
>
> This also promotes every other footer inconsistency to an assertion.
> Before, only a nid mismatch reached f2fs_bug_on(); the rest went through
> the helper's own path, which sets SBI_NEED_FSCK, warns and calls
> f2fs_handle_error(). After, any of them BUG() under CONFIG_F2FS_CHECK_FS.
For NODE_TYPE_REGULAR, add the case of “if(is_inode && is_xnode)” to
this flow,
aim to check return value of f2fs_sanity_check_node_footer && remove
redundant footer inconsistency check。
>
> The other two callers went the other way. __write_node_cache():
>
> if (f2fs_sanity_check_node_footer(sbi, entry, entry->index,
> NODE_TYPE_REGULAR, false)) {
> fserror_report_metadata(sbi->sb, -EFSCORRUPTED, GFP_NOFS);
> f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_CORRUPTED_NID);
> goto redirty_out;
> }
>
> and the read completion turns it into BLK_STS_IOERR. Worth a line in the
> changelog either way.
>
> FAULT_INCONSISTENT_FOOTER is injected inside that helper, so with
> CONFIG_F2FS_CHECK_FS=y injecting it now panics instead of exercising the
> error path. Deliberate?
oh ,sorry, I missed this, thansk for pointing it.