linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] f2fs: support in-memory inode checksum when checking consistency
@ 2018-03-08 21:31 Weichao Guo
  2018-03-09  5:49 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Weichao Guo @ 2018-03-08 21:31 UTC (permalink / raw)
  To: yuchao0, jaegeuk; +Cc: heyunlei, linux-f2fs-devel

Only enable in-memory inode checksum to protect metadata blocks
from in-memory scribbles when checking consistency, which has no
performance requirements.
---
 fs/f2fs/inode.c |  7 +++++++
 fs/f2fs/node.c  | 10 +++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 205add3..e405b28 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;
@@ -445,6 +449,9 @@ void update_inode(struct inode *inode, struct page *node_page)
 	if (inode->i_nlink == 0)
 		clear_inline_node(node_page);
 
+#ifdef CONFIG_F2FS_CHECK_FS
+	f2fs_inode_chksum_set(F2FS_I_SB(inode), node_page);
+#endif
 }
 
 void update_inode_page(struct inode *inode)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 177c438..6107935 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1113,8 +1113,12 @@ static int read_node_page(struct page *page, int op_flags)
 		.encrypted_page = NULL,
 	};
 
-	if (PageUptodate(page))
+	if (PageUptodate(page)) {
+#ifdef CONFIG_F2FS_CHECK_FS
+		f2fs_bug_on(sbi, !f2fs_inode_chksum_verify(sbi, page));
+#endif
 		return LOCKED_PAGE;
+	}
 
 	get_node_info(sbi, page->index, &ni);
 
@@ -1731,6 +1735,10 @@ static int f2fs_set_node_page_dirty(struct page *page)
 
 	if (!PageUptodate(page))
 		SetPageUptodate(page);
+#ifdef CONFIG_F2FS_CHECK_FS
+	if (IS_INODE(page))
+		f2fs_inode_chksum_set(F2FS_P_SB(page), page);
+#endif
 	if (!PageDirty(page)) {
 		f2fs_set_page_dirty_nobuffers(page);
 		inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
-- 
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] 3+ messages in thread

* Re: [PATCH v5] f2fs: support in-memory inode checksum when checking consistency
  2018-03-08 21:31 [PATCH v5] f2fs: support in-memory inode checksum when checking consistency Weichao Guo
@ 2018-03-09  5:49 ` Chao Yu
  2018-03-09  6:42   ` guoweichao
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2018-03-09  5:49 UTC (permalink / raw)
  To: Weichao Guo, jaegeuk; +Cc: heyunlei, linux-f2fs-devel

On 2018/3/9 5:31, Weichao Guo wrote:
> Only enable in-memory inode checksum to protect metadata blocks
> from in-memory scribbles when checking consistency, which has no
> performance requirements.

Signed-off-by?

Thanks,

> ---
>  fs/f2fs/inode.c |  7 +++++++
>  fs/f2fs/node.c  | 10 +++++++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index 205add3..e405b28 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;
> @@ -445,6 +449,9 @@ void update_inode(struct inode *inode, struct page *node_page)
>  	if (inode->i_nlink == 0)
>  		clear_inline_node(node_page);
>  
> +#ifdef CONFIG_F2FS_CHECK_FS
> +	f2fs_inode_chksum_set(F2FS_I_SB(inode), node_page);
> +#endif
>  }
>  
>  void update_inode_page(struct inode *inode)
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 177c438..6107935 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1113,8 +1113,12 @@ static int read_node_page(struct page *page, int op_flags)
>  		.encrypted_page = NULL,
>  	};
>  
> -	if (PageUptodate(page))
> +	if (PageUptodate(page)) {
> +#ifdef CONFIG_F2FS_CHECK_FS
> +		f2fs_bug_on(sbi, !f2fs_inode_chksum_verify(sbi, page));
> +#endif
>  		return LOCKED_PAGE;
> +	}
>  
>  	get_node_info(sbi, page->index, &ni);
>  
> @@ -1731,6 +1735,10 @@ static int f2fs_set_node_page_dirty(struct page *page)
>  
>  	if (!PageUptodate(page))
>  		SetPageUptodate(page);
> +#ifdef CONFIG_F2FS_CHECK_FS
> +	if (IS_INODE(page))
> +		f2fs_inode_chksum_set(F2FS_P_SB(page), page);
> +#endif
>  	if (!PageDirty(page)) {
>  		f2fs_set_page_dirty_nobuffers(page);
>  		inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
> 


------------------------------------------------------------------------------
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	[flat|nested] 3+ messages in thread

* Re: [PATCH v5] f2fs: support in-memory inode checksum when checking consistency
  2018-03-09  5:49 ` Chao Yu
@ 2018-03-09  6:42   ` guoweichao
  0 siblings, 0 replies; 3+ messages in thread
From: guoweichao @ 2018-03-09  6:42 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: heyunlei, linux-f2fs-devel



On 2018/3/9 13:49, Chao Yu wrote:
> On 2018/3/9 5:31, Weichao Guo wrote:
>> Only enable in-memory inode checksum to protect metadata blocks
>> from in-memory scribbles when checking consistency, which has no
>> performance requirements.
> 
> Signed-off-by?
Sorry for this mistake.
I will send a new version of this patch.
Thanks,
> 
> Thanks,
> 
>> ---
>>  fs/f2fs/inode.c |  7 +++++++
>>  fs/f2fs/node.c  | 10 +++++++++-
>>  2 files changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
>> index 205add3..e405b28 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;
>> @@ -445,6 +449,9 @@ void update_inode(struct inode *inode, struct page *node_page)
>>  	if (inode->i_nlink == 0)
>>  		clear_inline_node(node_page);
>>  
>> +#ifdef CONFIG_F2FS_CHECK_FS
>> +	f2fs_inode_chksum_set(F2FS_I_SB(inode), node_page);
>> +#endif
>>  }
>>  
>>  void update_inode_page(struct inode *inode)
>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> index 177c438..6107935 100644
>> --- a/fs/f2fs/node.c
>> +++ b/fs/f2fs/node.c
>> @@ -1113,8 +1113,12 @@ static int read_node_page(struct page *page, int op_flags)
>>  		.encrypted_page = NULL,
>>  	};
>>  
>> -	if (PageUptodate(page))
>> +	if (PageUptodate(page)) {
>> +#ifdef CONFIG_F2FS_CHECK_FS
>> +		f2fs_bug_on(sbi, !f2fs_inode_chksum_verify(sbi, page));
>> +#endif
>>  		return LOCKED_PAGE;
>> +	}
>>  
>>  	get_node_info(sbi, page->index, &ni);
>>  
>> @@ -1731,6 +1735,10 @@ static int f2fs_set_node_page_dirty(struct page *page)
>>  
>>  	if (!PageUptodate(page))
>>  		SetPageUptodate(page);
>> +#ifdef CONFIG_F2FS_CHECK_FS
>> +	if (IS_INODE(page))
>> +		f2fs_inode_chksum_set(F2FS_P_SB(page), page);
>> +#endif
>>  	if (!PageDirty(page)) {
>>  		f2fs_set_page_dirty_nobuffers(page);
>>  		inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
>>
> 
> 
> .
> 


------------------------------------------------------------------------------
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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-09  6:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-08 21:31 [PATCH v5] f2fs: support in-memory inode checksum when checking consistency Weichao Guo
2018-03-09  5:49 ` Chao Yu
2018-03-09  6:42   ` guoweichao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).