Skip to content

Commit 241d3c6

Browse files
taigerhugregkh
authored andcommitted
erofs: clean up z_erofs_pcluster_readmore()
[ Upstream commit 796e9149a2fcdba5543e247abd8d911a399bb9a6 ] `end` parameter is no needed since it's pointless for !backmost, we can handle it with backmost internally. And we only expand the trailing edge, so the newstart can be replaced with ->headoffset. Also, remove linux/prefetch.h inclusion since that is not used anymore after commit 3862929 ("erofs: introduce readmore decompression strategy"). Signed-off-by: Yue Hu <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Gao Xiang: update commit description. ] Signed-off-by: Gao Xiang <[email protected]> Stable-dep-of: 99f7619a77a0 ("erofs: fix to add missing tracepoint in erofs_read_folio()") Signed-off-by: Sasha Levin <[email protected]>
1 parent c34a8b0 commit 241d3c6

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

fs/erofs/zdata.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Copyright (C) 2022 Alibaba Cloud
66
*/
77
#include "compress.h"
8-
#include <linux/prefetch.h>
98
#include <linux/psi.h>
109

1110
#include <trace/events/erofs.h>
@@ -1630,28 +1629,28 @@ static void z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
16301629
*/
16311630
static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
16321631
struct readahead_control *rac,
1633-
erofs_off_t end,
1634-
struct page **pagepool,
1635-
bool backmost)
1632+
struct page **pagepool, bool backmost)
16361633
{
16371634
struct inode *inode = f->inode;
16381635
struct erofs_map_blocks *map = &f->map;
1639-
erofs_off_t cur;
1636+
erofs_off_t cur, end, headoffset = f->headoffset;
16401637
int err;
16411638

16421639
if (backmost) {
1640+
if (rac)
1641+
end = headoffset + readahead_length(rac) - 1;
1642+
else
1643+
end = headoffset + PAGE_SIZE - 1;
16431644
map->m_la = end;
16441645
err = z_erofs_map_blocks_iter(inode, map,
16451646
EROFS_GET_BLOCKS_READMORE);
16461647
if (err)
16471648
return;
16481649

1649-
/* expend ra for the trailing edge if readahead */
1650+
/* expand ra for the trailing edge if readahead */
16501651
if (rac) {
1651-
loff_t newstart = readahead_pos(rac);
1652-
16531652
cur = round_up(map->m_la + map->m_llen, PAGE_SIZE);
1654-
readahead_expand(rac, newstart, cur - newstart);
1653+
readahead_expand(rac, headoffset, cur - headoffset);
16551654
return;
16561655
}
16571656
end = round_up(end, PAGE_SIZE);
@@ -1699,10 +1698,9 @@ static int z_erofs_read_folio(struct file *file, struct folio *folio)
16991698
trace_erofs_readpage(page, false);
17001699
f.headoffset = (erofs_off_t)page->index << PAGE_SHIFT;
17011700

1702-
z_erofs_pcluster_readmore(&f, NULL, f.headoffset + PAGE_SIZE - 1,
1703-
&pagepool, true);
1701+
z_erofs_pcluster_readmore(&f, NULL, &pagepool, true);
17041702
err = z_erofs_do_read_page(&f, page, &pagepool);
1705-
z_erofs_pcluster_readmore(&f, NULL, 0, &pagepool, false);
1703+
z_erofs_pcluster_readmore(&f, NULL, &pagepool, false);
17061704

17071705
(void)z_erofs_collector_end(&f);
17081706

@@ -1728,8 +1726,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
17281726

17291727
f.headoffset = readahead_pos(rac);
17301728

1731-
z_erofs_pcluster_readmore(&f, rac, f.headoffset +
1732-
readahead_length(rac) - 1, &pagepool, true);
1729+
z_erofs_pcluster_readmore(&f, rac, &pagepool, true);
17331730
nr_pages = readahead_count(rac);
17341731
trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
17351732

@@ -1752,7 +1749,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
17521749
page->index, EROFS_I(inode)->nid);
17531750
put_page(page);
17541751
}
1755-
z_erofs_pcluster_readmore(&f, rac, 0, &pagepool, false);
1752+
z_erofs_pcluster_readmore(&f, rac, &pagepool, false);
17561753
(void)z_erofs_collector_end(&f);
17571754

17581755
z_erofs_runqueue(&f, &pagepool,

0 commit comments

Comments
 (0)