Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Chao Yu and committed by
Jaegeuk Kim
86109c90 240a5915

+8 -9
+8 -9
fs/f2fs/data.c
··· 1551 1551 if (last_block > last_block_in_file) 1552 1552 last_block = last_block_in_file; 1553 1553 1554 + /* just zeroing out page which is beyond EOF */ 1555 + if (block_in_file >= last_block) 1556 + goto zero_out; 1554 1557 /* 1555 1558 * Map blocks using the previous result first. 1556 1559 */ ··· 1566 1563 * Then do more f2fs_map_blocks() calls until we are 1567 1564 * done with this page. 1568 1565 */ 1569 - map.m_flags = 0; 1566 + map.m_lblk = block_in_file; 1567 + map.m_len = last_block - block_in_file; 1570 1568 1571 - if (block_in_file < last_block) { 1572 - map.m_lblk = block_in_file; 1573 - map.m_len = last_block - block_in_file; 1574 - 1575 - if (f2fs_map_blocks(inode, &map, 0, 1576 - F2FS_GET_BLOCK_DEFAULT)) 1577 - goto set_error_page; 1578 - } 1569 + if (f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_DEFAULT)) 1570 + goto set_error_page; 1579 1571 got_it: 1580 1572 if ((map.m_flags & F2FS_MAP_MAPPED)) { 1581 1573 block_nr = map.m_pblk + block_in_file - map.m_lblk; ··· 1585 1587 DATA_GENERIC)) 1586 1588 goto set_error_page; 1587 1589 } else { 1590 + zero_out: 1588 1591 zero_user_segment(page, 0, PAGE_SIZE); 1589 1592 if (!PageUptodate(page)) 1590 1593 SetPageUptodate(page);