nilfs2: replace WARN_ONs for invalid DAT metadata block requests
PATCH 1/1 nilfs2: replace WARN_ONs for invalid DAT metadata block requests
commit 5124a0a549857c4b87173280e192eea24dea72ad upstream.
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.
---
Please use this patch for these versions instead of the patch I asked you to drop in the previous review comments.
This replacement patch uses an equivalent call using nilfs_msg() instead of nilfs_err(), which does not exist in these versions.
Thanks,
Ryusuke Konishi
fs/nilfs2/dat.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
fs/nilfs2/dat.c +17 -10
@@ -40,8 +40,21 @@ static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat)static int nilfs_dat_prepare_entry (struct inode *dat,struct nilfs_palloc_req *req,int create) { -return nilfs_palloc_get_entry_block (dat, req->pr_entry_nr, - create, &req->pr_entry_bh); +int ret; + + ret =nilfs_palloc_get_entry_block (dat, req->pr_entry_nr, + create, &req->pr_entry_bh); +if (unlikely (ret == -ENOENT )) { +nilfs_msg (dat->i_sb,KERN_ERR , +"DAT doesn't have a block to manage vblocknr = %llu" , + (unsigned long long )req->pr_entry_nr); +/* +* Return internal code -EINVAL to notify bmap layer of +* metadata corruption. +*/ + ret = -EINVAL ; + } +return ret; } static void nilfs_dat_commit_entry(struct inode *dat,
@@ -123,11 +136,7 @@ static void nilfs_dat_commit_free(struct inode *dat,int nilfs_dat_prepare_start (struct inode *dat,struct nilfs_palloc_req *req) { -int ret; - - ret =nilfs_dat_prepare_entry (dat, req,0 ); -WARN_ON (ret == -ENOENT ); -return ret; +return nilfs_dat_prepare_entry (dat, req,0 ); } void nilfs_dat_commit_start(struct inode *dat, struct nilfs_palloc_req *req,
@@ -154,10 +163,8 @@ int nilfs_dat_prepare_end(struct inode *dat, struct nilfs_palloc_req *req)int ret; ret =nilfs_dat_prepare_entry (dat, req,0 ); -if (ret <0 ) { -WARN_ON (ret == -ENOENT ); +if (ret <0 )return ret; - } kaddr =kmap_atomic (req->pr_entry_bh->b_page); entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr,
Signature · 1 line
2.39.3
Greg Kroah-Hartman
maintainerQuoted 19 lines · Ryusuke Konishi
commit
5124a0a549857c4b87173280e192eea24dea72adupstream.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_ONsby error output, so that a kernel, booted withpanic_on_warn, does not panic. This patch also replaces the detected return code-ENOENTwith another internal code-EINVALto notify the bmap layer of metadata corruption. When the bmap layer sees-EINVAL, it handles the abnormal situation withnilfs_bmap_convert_error()and finally returns code-EIOas it should.Signed-off-by Ryusuke Konishi <[email protected]>Reported-by <[email protected]>Tested-by Ryusuke Konishi <[email protected]>Signed-off-by Andrew Morton <[email protected]>
Quoted 6 lines
---
Please use this patch for these versions instead of the patch I asked you to drop in the previous review comments.This replacement patch uses an equivalent call using
nilfs_msg()instead ofnilfs_err(), which does not exist in these versions.
Now queued up, thanks.
greg k-h