All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: in-memory inode checksum when checking consistency
@ 2018-02-22 18:24 Weichao Guo
  0 siblings, 0 replies; only message in thread
From: Weichao Guo @ 2018-02-22 18:24 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: heyunlei, linux-f2fs-devel

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 <guoweichao@huawei.com>
---
 fs/f2fs/inode.c | 7 +++++++
 fs/f2fs/node.c  | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 89c838b..cb51557 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
 	f2fs_put_page(node_page, 1);
 }
 
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 177c438..d76399d 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1191,11 +1191,16 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 		goto out_err;
 	}
 
+#ifdef CONFIG_F2FS_CHECK_FS
+page_hit:
+	BUG_ON(f2fs_inode_chksum_verify(sbi, page));
+#else
 	if (!f2fs_inode_chksum_verify(sbi, page)) {
 		err = -EBADMSG;
 		goto out_err;
 	}
 page_hit:
+#endif
 	if(unlikely(nid != nid_of_node(page))) {
 		f2fs_msg(sbi->sb, KERN_WARNING, "inconsistent node block, "
 			"nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-22 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 18:24 [PATCH] f2fs: in-memory inode checksum when checking consistency Weichao Guo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.