Skip to contentSkip to conversation

f2fs: in-memory inode checksum when checking consistency

PATCH Superseded Weichao Guo 1 participant 1 message Feb 22, 2018 F2FS file system

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: in-memory inode checksum when checking consistency

Enable in-memory inode checksum to protect metadata blocks from in-memory scribbles only when checking consistency with no performance requirements.

---
 fs/f2fs/inode.c | 7 +++++++
 fs/f2fs/node.c  | 5 +++++
 2 files changed, 12 insertions(+)
fs/f2fs/inode.c +7 -0
index 89c838b..cb51557 100644
@@ -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);
 }
 
fs/f2fs/node.c +5 -0
index 177c438..d76399d 100644
@@ -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]",
Signature · 6 lines
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