summaryrefslogtreecommitdiff
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2016-01-08 15:13:37 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2016-01-08 22:45:16 +0300
commite84587250ab7e38b7d85e93a8c317e065e5c0a1f (patch)
tree5828e5f3ed8e328376e87665fb73e5ac7ba799d2 /fs/f2fs/node.c
parentde1475cc53b2d6442443dcf5d66ed0fc50ed3c7e (diff)
downloadlinux-e84587250ab7e38b7d85e93a8c317e065e5c0a1f.tar.xz
f2fs: check node id earily when readaheading node page
Add node id check in ra_node_page and get_node_page_ra like get_node_page. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/node.c')
-rw-r--r--fs/f2fs/node.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 6d5f548d2090..c1ddf3d88dd9 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1041,6 +1041,10 @@ void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
struct page *apage;
int err;
+ if (!nid)
+ return;
+ f2fs_bug_on(sbi, check_nid_range(sbi, nid));
+
apage = find_get_page(NODE_MAPPING(sbi), nid);
if (apage && PageUptodate(apage)) {
f2fs_put_page(apage, 0);
@@ -1108,6 +1112,7 @@ struct page *get_node_page_ra(struct page *parent, int start)
nid = get_nid(parent, start, false);
if (!nid)
return ERR_PTR(-ENOENT);
+ f2fs_bug_on(sbi, check_nid_range(sbi, nid));
repeat:
page = grab_cache_page(NODE_MAPPING(sbi), nid);
if (!page)
@@ -1127,9 +1132,9 @@ repeat:
end = start + MAX_RA_NODE;
end = min(end, NIDS_PER_BLOCK);
for (i = start + 1; i < end; i++) {
- nid_t tnid = get_nid(parent, i, false);
- if (!tnid)
- continue;
+ nid_t tnid;
+
+ tnid = get_nid(parent, i, false);
ra_node_page(sbi, tnid);
}