Skip to content

Commit 1a4821a

Browse files
committed
erofs: convert z_erofs_pcluster_readmore() to folios
Unlike `pagecache_get_page()`, `__filemap_get_folio()` returns error pointers instead of NULL, thus switching to `IS_ERR_OR_NULL`. Apart from that, it's just a straightforward conversion. Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 256abd8 commit 1a4821a

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

fs/erofs/internal.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,13 @@ static inline unsigned int erofs_inode_datalayout(unsigned int ifmt)
312312
return (ifmt >> EROFS_I_DATALAYOUT_BIT) & EROFS_I_DATALAYOUT_MASK;
313313
}
314314

315-
/*
316-
* Different from grab_cache_page_nowait(), reclaiming is never triggered
317-
* when allocating new pages.
318-
*/
319-
static inline
320-
struct page *erofs_grab_cache_page_nowait(struct address_space *mapping,
321-
pgoff_t index)
315+
/* reclaiming is never triggered when allocating new folios. */
316+
static inline struct folio *erofs_grab_folio_nowait(struct address_space *as,
317+
pgoff_t index)
322318
{
323-
return pagecache_get_page(mapping, index,
319+
return __filemap_get_folio(as, index,
324320
FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
325-
readahead_gfp_mask(mapping) & ~__GFP_RECLAIM);
321+
readahead_gfp_mask(as) & ~__GFP_RECLAIM);
326322
}
327323

328324
/* Has a disk mapping */

fs/erofs/zdata.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,23 +1767,22 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
17671767
end = round_up(end, PAGE_SIZE);
17681768
} else {
17691769
end = round_up(map->m_la, PAGE_SIZE);
1770-
17711770
if (!map->m_llen)
17721771
return;
17731772
}
17741773

17751774
cur = map->m_la + map->m_llen - 1;
17761775
while ((cur >= end) && (cur < i_size_read(inode))) {
17771776
pgoff_t index = cur >> PAGE_SHIFT;
1778-
struct page *page;
1777+
struct folio *folio;
17791778

1780-
page = erofs_grab_cache_page_nowait(inode->i_mapping, index);
1781-
if (page) {
1782-
if (PageUptodate(page))
1783-
unlock_page(page);
1779+
folio = erofs_grab_folio_nowait(inode->i_mapping, index);
1780+
if (!IS_ERR_OR_NULL(folio)) {
1781+
if (folio_test_uptodate(folio))
1782+
folio_unlock(folio);
17841783
else
1785-
z_erofs_scan_folio(f, page_folio(page), !!rac);
1786-
put_page(page);
1784+
z_erofs_scan_folio(f, folio, !!rac);
1785+
folio_put(folio);
17871786
}
17881787

17891788
if (cur < PAGE_SIZE)

0 commit comments

Comments
 (0)