f2fs: don't check inode's checksum if it was dirtied or writebacked
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 31 Aug 2017 23:54:51 +0000 (16:54 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 5 Sep 2017 17:50:11 +0000 (10:50 -0700)
If another thread already made the page dirtied or writebacked, we must avoid
to verify checksum. If we got an error, we need to remove its uptodate as well.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/inode.c
fs/f2fs/node.c

index b4c401d456e7e3cafd95a820405b792f760ec7ff..c33b05aec1a1fa24e542b4e09f57d29c0a73336e 100644 (file)
@@ -153,7 +153,8 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
        struct f2fs_inode *ri;
        __u32 provided, calculated;
 
-       if (!f2fs_enable_inode_chksum(sbi, page))
+       if (!f2fs_enable_inode_chksum(sbi, page) ||
+                       PageDirty(page) || PageWriteback(page))
                return true;
 
        ri = &F2FS_NODE(page)->i;
index 388a00262a5f5cfeaec584454abfe30dc200547d..fca87835a1da3f19a36a651f71493397e0fd7f8c 100644 (file)
@@ -1187,9 +1187,9 @@ page_hit:
                        nid, nid_of_node(page), ino_of_node(page),
                        ofs_of_node(page), cpver_of_node(page),
                        next_blkaddr_of_node(page));
-               ClearPageUptodate(page);
                err = -EINVAL;
 out_err:
+               ClearPageUptodate(page);
                f2fs_put_page(page, 1);
                return ERR_PTR(err);
        }