Skip to content

Commit 936aa70

Browse files
Chunhai Guohsiangkao
authored andcommitted
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: Chunhai Guo <guochunhai@vivo.com> Fixes: 3862929 ("erofs: introduce readmore decompression strategy") Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Yue Hu <huyue2@coolpad.com> Reviewed-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20230710042531.28761-1-guochunhai@vivo.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent c553976 commit 936aa70

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/erofs/zdata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
18411841
}
18421842

18431843
cur = map->m_la + map->m_llen - 1;
1844-
while (cur >= end) {
1844+
while ((cur >= end) && (cur < i_size_read(inode))) {
18451845
pgoff_t index = cur >> PAGE_SHIFT;
18461846
struct page *page;
18471847

0 commit comments

Comments
 (0)