Re: [PATCH] f2fs: don't BUG_ON a missing orphan inode at mount

From: Chao Yu

Date: Wed Nov 11 2026 - 03:40:32 EST


On 11/5/26 11:44, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
>
> recover_orphan_inode() treats -ENOENT from f2fs_iget() as a kernel
> bug, but the ino comes from the on-disk orphan block. An image whose
> orphan entry names an inode without a NAT entry hits the BUG_ON at
> mount with CONFIG_F2FS_CHECK_FS, or a WARN and a failed mount
> without it.
>
> To reproduce, unlink a file while it is still open, sync, crash,
> then change ino[0] in the checkpoint's orphan block to an unused
> nid and mount:
>
> kernel BUG at fs/f2fs/checkpoint.c:967!
> RIP: 0010:f2fs_recover_orphan_inodes+0x6a3/0x9a0
>
> Treat it as corruption, the same way the entry_count check does:
> fail the mount with -EFSCORRUPTED and record
> ERROR_INCONSISTENT_ORPHAN for fsck.
>
> Fixes: 8c14bfadeac2 ("f2fs: handle error of f2fs_iget correctly")
> Reported-by: Guikun Yang <yangguikun19@xxxxxx>
> Closes: https://lore.kernel.org/linux-f2fs-devel/tencent_B30A444DF94444D1A63A7D6F8E2039F1990A@xxxxxx/
> Cc: stable@xxxxxxxxxx
> Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,