On 2018/2/27 3:28, Weichao Guo wrote: > Enable in-memory inode checksum to protect metadata blocks > from in-memory scribbles only when checking consistency with > no performance requirements. > > Signed-off-by: Weichao Guo <guoweic...@huawei.com> > --- > fs/f2fs/inode.c | 7 +++++++ > fs/f2fs/node.c | 4 +++- > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > index 205add3d0f3a..b04129d23d21 100644 > --- a/fs/f2fs/inode.c > +++ b/fs/f2fs/inode.c > @@ -159,8 +159,12 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, > struct page *page) > struct f2fs_inode *ri; > __u32 provided, calculated; > > +#ifdef CONFIG_F2FS_CHECK_FS > + if (!f2fs_enable_inode_chksum(sbi, page)) > +#else > if (!f2fs_enable_inode_chksum(sbi, page) || > PageDirty(page) || PageWriteback(page)) > +#endif > return true; > > ri = &F2FS_NODE(page)->i; > @@ -464,6 +468,9 @@ void update_inode_page(struct inode *inode) > return; > } > update_inode(inode, node_page); > +#ifdef CONFIG_F2FS_CHECK_FS > + f2fs_inode_chksum_set(sbi, node_page); > +#endif
> This gives a panic easily by fsstress. Could you please check it again? Sorry, I missed some cases, it looks that we need to cover updating place of all fields like i_addr, inline_xxx, footer with f2fs_inode_chksum_set. Thanks, > f2fs_put_page(node_page, 1); > } > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index 177c438e4a56..2adeb74ae055 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -1113,8 +1113,10 @@ static int read_node_page(struct page *page, int > op_flags) > .encrypted_page = NULL, > }; > > - if (PageUptodate(page)) > + if (PageUptodate(page)) { > + f2fs_bug_on(sbi, !f2fs_inode_chksum_verify(sbi, page)); > return LOCKED_PAGE; > + } > > get_node_info(sbi, page->index, &ni); > > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel