diff options
author | Chao Yu <yuchao0@huawei.com> | 2019-03-07 17:31:30 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2019-03-12 18:59:19 -0700 |
commit | 86109c9064daf2ac44ef7b4f1eeb039260351e9c (patch) | |
tree | d7f9eefc291c0b52c0d597e58bc3d754713f0bd8 /fs/f2fs/data.c | |
parent | 240a59156d9bcfabceddb66be449e7b32fb5dc4a (diff) | |
download | linux-86109c9064daf2ac44ef7b4f1eeb039260351e9c.tar.bz2 |
f2fs: don't trigger read IO for beyond EOF page
In f2fs_mpage_readpages(), if page is beyond EOF, we should just
zero out it, but previously, before checking previous mapping
info, we missed to check filesize boundary, fix it.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index fa6318549af5..912fdcc2dbb8 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1551,6 +1551,9 @@ static int f2fs_mpage_readpages(struct address_space *mapping, if (last_block > last_block_in_file) last_block = last_block_in_file; + /* just zeroing out page which is beyond EOF */ + if (block_in_file >= last_block) + goto zero_out; /* * Map blocks using the previous result first. */ @@ -1563,16 +1566,11 @@ static int f2fs_mpage_readpages(struct address_space *mapping, * Then do more f2fs_map_blocks() calls until we are * done with this page. */ - map.m_flags = 0; + map.m_lblk = block_in_file; + map.m_len = last_block - block_in_file; - if (block_in_file < last_block) { - map.m_lblk = block_in_file; - map.m_len = last_block - block_in_file; - - if (f2fs_map_blocks(inode, &map, 0, - F2FS_GET_BLOCK_DEFAULT)) - goto set_error_page; - } + if (f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_DEFAULT)) + goto set_error_page; got_it: if ((map.m_flags & F2FS_MAP_MAPPED)) { block_nr = map.m_pblk + block_in_file - map.m_lblk; @@ -1587,6 +1585,7 @@ got_it: DATA_GENERIC)) goto set_error_page; } else { +zero_out: zero_user_segment(page, 0, PAGE_SIZE); if (!PageUptodate(page)) SetPageUptodate(page); |