mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-20 14:16:02 +00:00
f2fs: return the errno to the caller to avoid using a wrong page
Commitaaf9607516
("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, commite1c51b9f1d
("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>
This commit is contained in:
parent
46ae957f9b
commit
0c9df7fb80
1 changed files with 10 additions and 5 deletions
|
@ -1142,16 +1142,21 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
|
|||
|
||||
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:
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue