Skip to content

Commit 0e25a78

Browse files
committed
erofs: convert z_erofs_do_read_page() to folios
It is a straight-forward conversion. Besides, it's renamed as z_erofs_scan_folio(). Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20240305091448.1384242-2-hsiangkao@linux.alibaba.com
1 parent d136d33 commit 0e25a78

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

fs/erofs/zdata.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -955,21 +955,20 @@ static int z_erofs_read_fragment(struct super_block *sb, struct page *page,
955955
return 0;
956956
}
957957

958-
static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
959-
struct page *page, bool ra)
958+
static int z_erofs_scan_folio(struct z_erofs_decompress_frontend *fe,
959+
struct folio *folio, bool ra)
960960
{
961-
struct folio *folio = page_folio(page);
962961
struct inode *const inode = fe->inode;
963962
struct erofs_map_blocks *const map = &fe->map;
964-
const loff_t offset = page_offset(page);
965-
const unsigned int bs = i_blocksize(inode);
963+
const loff_t offset = folio_pos(folio);
964+
const unsigned int bs = i_blocksize(inode), fs = folio_size(folio);
966965
bool tight = true, exclusive;
967966
unsigned int cur, end, len, split;
968967
int err = 0;
969968

970969
z_erofs_onlinefolio_init(folio);
971970
split = 0;
972-
end = PAGE_SIZE;
971+
end = fs;
973972
repeat:
974973
if (offset + end - 1 < map->m_la ||
975974
offset + end - 1 >= map->m_la + map->m_llen) {
@@ -986,7 +985,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
986985
++split;
987986

988987
if (!(map->m_flags & EROFS_MAP_MAPPED)) {
989-
zero_user_segment(page, cur, end);
988+
folio_zero_segment(folio, cur, end);
990989
tight = false;
991990
goto next_part;
992991
}
@@ -995,8 +994,8 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
995994
erofs_off_t fpos = offset + cur - map->m_la;
996995

997996
len = min_t(unsigned int, map->m_llen - fpos, end - cur);
998-
err = z_erofs_read_fragment(inode->i_sb, page, cur, cur + len,
999-
EROFS_I(inode)->z_fragmentoff + fpos);
997+
err = z_erofs_read_fragment(inode->i_sb, &folio->page, cur,
998+
cur + len, EROFS_I(inode)->z_fragmentoff + fpos);
1000999
if (err)
10011000
goto out;
10021001
tight = false;
@@ -1011,18 +1010,18 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
10111010
}
10121011

10131012
/*
1014-
* Ensure the current partial page belongs to this submit chain rather
1013+
* Ensure the current partial folio belongs to this submit chain rather
10151014
* than other concurrent submit chains or the noio(bypass) chain since
1016-
* those chains are handled asynchronously thus the page cannot be used
1015+
* those chains are handled asynchronously thus the folio cannot be used
10171016
* for inplace I/O or bvpage (should be processed in a strict order.)
10181017
*/
10191018
tight &= (fe->mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE);
1020-
exclusive = (!cur && ((split <= 1) || (tight && bs == PAGE_SIZE)));
1019+
exclusive = (!cur && ((split <= 1) || (tight && bs == fs)));
10211020
if (cur)
10221021
tight &= (fe->mode >= Z_EROFS_PCLUSTER_FOLLOWED);
10231022

10241023
err = z_erofs_attach_page(fe, &((struct z_erofs_bvec) {
1025-
.page = page,
1024+
.page = &folio->page,
10261025
.offset = offset - map->m_la,
10271026
.end = end,
10281027
}), exclusive);
@@ -1789,7 +1788,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
17891788
if (PageUptodate(page))
17901789
unlock_page(page);
17911790
else
1792-
(void)z_erofs_do_read_page(f, page, !!rac);
1791+
z_erofs_scan_folio(f, page_folio(page), !!rac);
17931792
put_page(page);
17941793
}
17951794

@@ -1810,7 +1809,7 @@ static int z_erofs_read_folio(struct file *file, struct folio *folio)
18101809
f.headoffset = (erofs_off_t)folio->index << PAGE_SHIFT;
18111810

18121811
z_erofs_pcluster_readmore(&f, NULL, true);
1813-
err = z_erofs_do_read_page(&f, &folio->page, false);
1812+
err = z_erofs_scan_folio(&f, folio, false);
18141813
z_erofs_pcluster_readmore(&f, NULL, false);
18151814
z_erofs_pcluster_end(&f);
18161815

@@ -1851,7 +1850,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
18511850
folio = head;
18521851
head = folio_get_private(folio);
18531852

1854-
err = z_erofs_do_read_page(&f, &folio->page, true);
1853+
err = z_erofs_scan_folio(&f, folio, true);
18551854
if (err && err != -EINTR)
18561855
erofs_err(inode->i_sb, "readahead error at folio %lu @ nid %llu",
18571856
folio->index, EROFS_I(inode)->nid);

0 commit comments

Comments
 (0)