nilfs2: replace WARN_ONs for invalid DAT metadata block requests
authorRyusuke Konishi <konishi.ryusuke@gmail.com>
Thu, 26 Jan 2023 16:41:14 +0000 (01:41 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 3 Feb 2023 06:50:08 +0000 (22:50 -0800)
commit5124a0a549857c4b87173280e192eea24dea72ad
treeb73bb59101b8f0f8e04c550c3a31aaf9e9561304
parent1b381f6fe495fffbbdace1ee530afb74287c809d
nilfs2: replace WARN_ONs for invalid DAT metadata block requests

If DAT metadata file block access fails due to corruption of the DAT file
or abnormal virtual block numbers held by b-trees or inodes, a kernel
warning is generated.

This replaces the WARN_ONs by error output, so that a kernel, booted with
panic_on_warn, does not panic.  This patch also replaces the detected
return code -ENOENT with another internal code -EINVAL to notify the bmap
layer of metadata corruption.  When the bmap layer sees -EINVAL, it
handles the abnormal situation with nilfs_bmap_convert_error() and finally
returns code -EIO as it should.

Link: https://lkml.kernel.org/r/0000000000005cc3d205ea23ddcf@google.com
Link: https://lkml.kernel.org/r/20230126164114.6911-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: <syzbot+5d5d25f90f195a3cfcb4@syzkaller.appspotmail.com>
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/nilfs2/dat.c