Chao Yu via Linux-f2fs-devel <[email protected]>
于2025年12月15日周一 20:34写道:
>
> In order to avoid loading corrupted nat entry from disk.
>
> Cc: [email protected]
> Signed-off-by: Chao Yu <[email protected]>
> ---
>  fs/f2fs/node.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index ce471e033774..13c88dfd790d 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -630,14 +630,15 @@ int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t 
> nid,
>         node_info_from_raw_nat(ni, &ne);
>         f2fs_folio_put(folio, true);
>  sanity_check:
> -       if (__is_valid_data_blkaddr(ni->blk_addr) &&
> +       if (unlikely(ni->nid != nid ||
Hi Chao,
(ni->nid==nid) should be always true? because the code:

ni->flag = 0;
ni->nid = nid;
retry:
or am I missing something?

> +               (__is_valid_data_blkaddr(ni->blk_addr) &&
btw, Is it possible to detect that some valid Nid entries contain
incorrect content?
such as  ino/block_addr=NULL_ADDR in nid=4 entry?
Thanks
>                 !f2fs_is_valid_blkaddr(sbi, ni->blk_addr,
> -                                       DATA_GENERIC_ENHANCE)) {
> +                                       DATA_GENERIC_ENHANCE)))) {
>                 set_sbi_flag(sbi, SBI_NEED_FSCK);
>                 f2fs_err_ratelimited(sbi,
> -                       "f2fs_get_node_info of %pS: inconsistent nat entry, "
> +                       "f2fs_get_node_info of %pS: nid:%u, inconsistent nat 
> entry, "
>                         "ino:%u, nid:%u, blkaddr:%u, ver:%u, flag:%u",
> -                       __builtin_return_address(0),
> +                       __builtin_return_address(0), nid,
>                         ni->ino, ni->nid, ni->blk_addr, ni->version, 
> ni->flag);
>                 f2fs_handle_error(sbi, ERROR_INCONSISTENT_NAT);
>                 return -EFSCORRUPTED;
> --
> 2.49.0
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to