All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weichao Guo <guoweichao@huawei.com>
To: jaegeuk@kernel.org, yuchao0@huawei.com
Cc: heyunlei@huawei.com, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH] f2fs: in-memory inode checksum when checking consistency
Date: Fri, 23 Feb 2018 02:24:39 +0800	[thread overview]
Message-ID: <20180222182439.185402-1-guoweichao@huawei.com> (raw)

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

                 reply	other threads:[~2018-02-22 10:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180222182439.185402-1-guoweichao@huawei.com \
    --to=guoweichao@huawei.com \
    --cc=heyunlei@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.