aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2016-05-26 19:40:29 +0800
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:33:41 +0200
commitda1763768f2497a7c4abb9b3a0404ac95a5d693d (patch)
tree147dd8c10c70beae184ef1ddbdebd7121526738e /fs/f2fs/node.c
parent878811f2e92f1d01cfad6d857ffcb79c26358d58 (diff)
f2fs: return the errno to the caller to avoid using a wrong page
Commit aaf9607516ed38825268515ef4d773289a44f429 ("f2fs: check node page contents all the time") pointed out that "sometimes it was reported that its contents was missing", so it checks the page's mapping and contents. When "nid != nid_of_node(page)", ERR_PTR(-EIO) will be returned to the caller. However, commit e1c51b9f1df2f9efc2ec11488717e40cd12015f9 ("f2fs: clean up node page updating flow") moves "nid != nid_of_node(page)" test to "f2fs_bug_on(sbi, nid != nid_of_node(page))", this will return a wrong page to the caller when F2FS_CHECK_FS is off when "sometimes it was reported that its contents was missing" happens. This patch restores to check node page contents all the time, and returns the errno to make the caller known something is wrong and avoid to use the page. This patch also moves f2fs_bug_on to its proper location. Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Conflicts: fs/f2fs/node.c
Diffstat (limited to 'fs/f2fs/node.c')
-rw-r--r--fs/f2fs/node.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 7c1b03581..33c2d6c9c 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1152,17 +1152,23 @@ repeat:
lock_page(page);
- if (unlikely(!PageUptodate(page))) {
- f2fs_put_page(page, 1);
- return ERR_PTR(-EIO);
- }
+ if (unlikely(!PageUptodate(page)))
+ goto out_err;
+
if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
f2fs_put_page(page, 1);
goto repeat;
}
page_hit:
mark_page_accessed(page);
- f2fs_bug_on(sbi, nid != nid_of_node(page));
+
+ if(unlikely(nid != nid_of_node(page))) {
+ f2fs_bug_on(sbi, 1);
+ ClearPageUptodate(page);
+out_err:
+ f2fs_put_page(page, 1);
+ return ERR_PTR(-EIO);
+ }
return page;
}