Skip to contentSkip to conversation

f2fs: in-memory inode checksum when checking consistency

PATCH Chao Yu 3 participants 4 messages Feb 27, 2018 – Feb 28, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Chao Yu

author Reviewed-by
#1 lore raw
Quoted 5 lines · Weichao Guo

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

Thanks,

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

#2 lore raw
Quoted 8 lines · Chao Yu
Quoted 5 lines · Weichao Guo

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

This gives a panic easily by fsstress. Could you please check it again?

Thanks,

Quoted 2 lines

Thanks,

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

author
#3 lore raw
In reply to a message not in the archive
Quoted 35 lines · Weichao Guo

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  | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +7 -0
index 205add3d0f3a..b04129d23d21 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
 
Quoted 1 line

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,

Quoted 10 lines
fs/f2fs/inode.c +0 -0
 	f2fs_put_page(node_page, 1);
 }
fs/f2fs/node.c +0 -0
index 177c438e4a56..2adeb74ae055 100644
@@ -1113,8 +1113,10 @@ static int read_node_page(struct page *page, int op_flags)
 		.encrypted_page = NULL,

fs/f2fs/node.c static int read_node_page(struct page *page, int op_flags) · line 1122

Quoted 10 lines
fs/f2fs/node.c +3 -1
 	};
 
-	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

#4 lore raw
Quoted 36 lines · Chao Yu
Quoted 34 lines · Weichao Guo

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  | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +7 -0
index 205add3d0f3a..b04129d23d21 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
Quoted 5 lines
Quoted 1 line

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.

Sorry for that , I will do more test in the following. Thanks,

Quoted 19 lines

Thanks,

Quoted 17 lines
fs/f2fs/inode.c +0 -0
 	f2fs_put_page(node_page, 1);
 }
fs/f2fs/node.c +3 -1
index 177c438e4a56..2adeb74ae055 100644
@@ -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;
+	}
 
Quoted 7 lines

fs/f2fs/node.c static int read_node_page(struct page *page, int op_flags) · line 1122

Quoted 3 lines
fs/f2fs/node.c +0 -0
 	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