Commit 936aa701 authored by Chunhai Guo's avatar Chunhai Guo Committed by Gao Xiang

erofs: avoid useless loops in z_erofs_pcluster_readmore() when reading beyond EOF

z_erofs_pcluster_readmore() may take a long time to loop when the page
offset is large enough, which is unnecessary should be prevented.

For example, when the following case is encountered, it will loop 4691368
times, taking about 27 seconds:
    - offset = 19217289215
    - inode_size = 1442672
Signed-off-by: default avatarChunhai Guo <guochunhai@vivo.com>
Fixes: 38629291 ("erofs: introduce readmore decompression strategy")
Reviewed-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: default avatarYue Hu <huyue2@coolpad.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20230710042531.28761-1-guochunhai@vivo.comSigned-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
parent c5539762
......@@ -1841,7 +1841,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
}
cur = map->m_la + map->m_llen - 1;
while (cur >= end) {
while ((cur >= end) && (cur < i_size_read(inode))) {
pgoff_t index = cur >> PAGE_SHIFT;
struct page *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