Commit e1c51b9f authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: clean up node page updating flow



If read_node_page return LOCKED_PAGE, in its caller it's better a) skip
unneeded 'Update' flag and mapping info verfication; b) check nid value
stored in footer structure of node page.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent ea212a4a
...@@ -1063,12 +1063,13 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) ...@@ -1063,12 +1063,13 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
if (err < 0) { if (err < 0) {
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
return ERR_PTR(err); return ERR_PTR(err);
} else if (err != LOCKED_PAGE) { } else if (err == LOCKED_PAGE) {
lock_page(page); goto page_hit;
} }
if (unlikely(!PageUptodate(page) || nid != nid_of_node(page))) { lock_page(page);
ClearPageUptodate(page);
if (unlikely(!PageUptodate(page))) {
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
...@@ -1076,6 +1077,8 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) ...@@ -1076,6 +1077,8 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
goto repeat; goto repeat;
} }
page_hit:
f2fs_bug_on(sbi, nid != nid_of_node(page));
return page; return page;
} }
...@@ -1114,24 +1117,25 @@ struct page *get_node_page_ra(struct page *parent, int start) ...@@ -1114,24 +1117,25 @@ struct page *get_node_page_ra(struct page *parent, int start)
end = start + MAX_RA_NODE; end = start + MAX_RA_NODE;
end = min(end, NIDS_PER_BLOCK); end = min(end, NIDS_PER_BLOCK);
for (i = start + 1; i < end; i++) { for (i = start + 1; i < end; i++) {
nid = get_nid(parent, i, false); nid_t tnid = get_nid(parent, i, false);
if (!nid) if (!tnid)
continue; continue;
ra_node_page(sbi, nid); ra_node_page(sbi, tnid);
} }
blk_finish_plug(&plug); blk_finish_plug(&plug);
lock_page(page); lock_page(page);
if (unlikely(!PageUptodate(page))) {
f2fs_put_page(page, 1);
return ERR_PTR(-EIO);
}
if (unlikely(page->mapping != NODE_MAPPING(sbi))) { if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
goto repeat; goto repeat;
} }
page_hit: page_hit:
if (unlikely(!PageUptodate(page))) { f2fs_bug_on(sbi, nid != nid_of_node(page));
f2fs_put_page(page, 1);
return ERR_PTR(-EIO);
}
return page; return page;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment