Skip to content

Commit 491b110

Browse files
committed
erofs: adapt folios for z_erofs_readahead()
It's a straight-forward conversion except that readahead_folio() will do folio_put() in advance but it doesn't matter since folios are still locked. As before, since file-backed folios (pages for now) are locked, so we could temporarily use folio->private as an internal counter to indicate split parts of each folio for the corresponding pclusters to decompress. When such counter becomes zero, the folio will be finally unlocked (see compress.h and z_erofs_onlinepage_endio()). Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 06ec036 commit 491b110

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

fs/erofs/zdata.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,37 +1853,35 @@ static void z_erofs_readahead(struct readahead_control *rac)
18531853
struct inode *const inode = rac->mapping->host;
18541854
struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
18551855
struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
1856-
struct page *head = NULL, *page;
1857-
unsigned int nr_pages;
1856+
struct folio *head = NULL, *folio;
1857+
unsigned int nr_folios;
1858+
int err;
18581859

18591860
f.headoffset = readahead_pos(rac);
18601861

18611862
z_erofs_pcluster_readmore(&f, rac, true);
1862-
nr_pages = readahead_count(rac);
1863-
trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
1863+
nr_folios = readahead_count(rac);
1864+
trace_erofs_readpages(inode, readahead_index(rac), nr_folios, false);
18641865

1865-
while ((page = readahead_page(rac))) {
1866-
set_page_private(page, (unsigned long)head);
1867-
head = page;
1866+
while ((folio = readahead_folio(rac))) {
1867+
folio->private = head;
1868+
head = folio;
18681869
}
18691870

1871+
/* traverse in reverse order for best metadata I/O performance */
18701872
while (head) {
1871-
struct page *page = head;
1872-
int err;
1873-
1874-
/* traversal in reverse order */
1875-
head = (void *)page_private(page);
1873+
folio = head;
1874+
head = folio_get_private(folio);
18761875

1877-
err = z_erofs_do_read_page(&f, page);
1876+
err = z_erofs_do_read_page(&f, &folio->page);
18781877
if (err && err != -EINTR)
1879-
erofs_err(inode->i_sb, "readahead error %d @ %lu of nid %llu",
1880-
err, page->index, EROFS_I(inode)->nid);
1881-
put_page(page);
1878+
erofs_err(inode->i_sb, "readahead error at folio %lu @ nid %llu",
1879+
folio->index, EROFS_I(inode)->nid);
18821880
}
18831881
z_erofs_pcluster_readmore(&f, rac, false);
18841882
z_erofs_pcluster_end(&f);
18851883

1886-
z_erofs_runqueue(&f, z_erofs_is_sync_decompress(sbi, nr_pages), true);
1884+
z_erofs_runqueue(&f, z_erofs_is_sync_decompress(sbi, nr_folios), true);
18871885
erofs_put_metabuf(&f.map.buf);
18881886
erofs_release_pages(&f.pagepool);
18891887
}

0 commit comments

Comments
 (0)