Skip to content

Commit 796e914

Browse files
taigerhuhsiangkao
authored andcommitted
erofs: clean up z_erofs_pcluster_readmore()
`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]>
1 parent ef4b4b4 commit 796e914

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
#include <linux/cpuhotplug.h>
1110
#include <trace/events/erofs.h>
@@ -1825,28 +1824,28 @@ static void z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
18251824
*/
18261825
static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
18271826
struct readahead_control *rac,
1828-
erofs_off_t end,
1829-
struct page **pagepool,
1830-
bool backmost)
1827+
struct page **pagepool, bool backmost)
18311828
{
18321829
struct inode *inode = f->inode;
18331830
struct erofs_map_blocks *map = &f->map;
1834-
erofs_off_t cur;
1831+
erofs_off_t cur, end, headoffset = f->headoffset;
18351832
int err;
18361833

18371834
if (backmost) {
1835+
if (rac)
1836+
end = headoffset + readahead_length(rac) - 1;
1837+
else
1838+
end = headoffset + PAGE_SIZE - 1;
18381839
map->m_la = end;
18391840
err = z_erofs_map_blocks_iter(inode, map,
18401841
EROFS_GET_BLOCKS_READMORE);
18411842
if (err)
18421843
return;
18431844

1844-
/* expend ra for the trailing edge if readahead */
1845+
/* expand ra for the trailing edge if readahead */
18451846
if (rac) {
1846-
loff_t newstart = readahead_pos(rac);
1847-
18481847
cur = round_up(map->m_la + map->m_llen, PAGE_SIZE);
1849-
readahead_expand(rac, newstart, cur - newstart);
1848+
readahead_expand(rac, headoffset, cur - headoffset);
18501849
return;
18511850
}
18521851
end = round_up(end, PAGE_SIZE);
@@ -1894,10 +1893,9 @@ static int z_erofs_read_folio(struct file *file, struct folio *folio)
18941893
trace_erofs_readpage(page, false);
18951894
f.headoffset = (erofs_off_t)page->index << PAGE_SHIFT;
18961895

1897-
z_erofs_pcluster_readmore(&f, NULL, f.headoffset + PAGE_SIZE - 1,
1898-
&pagepool, true);
1896+
z_erofs_pcluster_readmore(&f, NULL, &pagepool, true);
18991897
err = z_erofs_do_read_page(&f, page, &pagepool);
1900-
z_erofs_pcluster_readmore(&f, NULL, 0, &pagepool, false);
1898+
z_erofs_pcluster_readmore(&f, NULL, &pagepool, false);
19011899

19021900
(void)z_erofs_collector_end(&f);
19031901

@@ -1923,8 +1921,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
19231921

19241922
f.headoffset = readahead_pos(rac);
19251923

1926-
z_erofs_pcluster_readmore(&f, rac, f.headoffset +
1927-
readahead_length(rac) - 1, &pagepool, true);
1924+
z_erofs_pcluster_readmore(&f, rac, &pagepool, true);
19281925
nr_pages = readahead_count(rac);
19291926
trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
19301927

@@ -1947,7 +1944,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
19471944
page->index, EROFS_I(inode)->nid);
19481945
put_page(page);
19491946
}
1950-
z_erofs_pcluster_readmore(&f, rac, 0, &pagepool, false);
1947+
z_erofs_pcluster_readmore(&f, rac, &pagepool, false);
19511948
(void)z_erofs_collector_end(&f);
19521949

19531950
z_erofs_runqueue(&f, &pagepool,

0 commit comments

Comments
 (0)