Commit 1a4821a0 authored by Gao Xiang's avatar Gao Xiang

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: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240703120051.3653452-1-hsiangkao@linux.alibaba.com
parent 256abd8e
...@@ -312,17 +312,13 @@ static inline unsigned int erofs_inode_datalayout(unsigned int ifmt) ...@@ -312,17 +312,13 @@ static inline unsigned int erofs_inode_datalayout(unsigned int ifmt)
return (ifmt >> EROFS_I_DATALAYOUT_BIT) & EROFS_I_DATALAYOUT_MASK; return (ifmt >> EROFS_I_DATALAYOUT_BIT) & EROFS_I_DATALAYOUT_MASK;
} }
/* /* reclaiming is never triggered when allocating new folios. */
* Different from grab_cache_page_nowait(), reclaiming is never triggered static inline struct folio *erofs_grab_folio_nowait(struct address_space *as,
* when allocating new pages. pgoff_t index)
*/
static inline
struct page *erofs_grab_cache_page_nowait(struct address_space *mapping,
pgoff_t index)
{ {
return pagecache_get_page(mapping, index, return __filemap_get_folio(as, index,
FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT, FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
readahead_gfp_mask(mapping) & ~__GFP_RECLAIM); readahead_gfp_mask(as) & ~__GFP_RECLAIM);
} }
/* Has a disk mapping */ /* Has a disk mapping */
......
...@@ -1767,7 +1767,6 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f, ...@@ -1767,7 +1767,6 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
end = round_up(end, PAGE_SIZE); end = round_up(end, PAGE_SIZE);
} else { } else {
end = round_up(map->m_la, PAGE_SIZE); end = round_up(map->m_la, PAGE_SIZE);
if (!map->m_llen) if (!map->m_llen)
return; return;
} }
...@@ -1775,15 +1774,15 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f, ...@@ -1775,15 +1774,15 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
cur = map->m_la + map->m_llen - 1; cur = map->m_la + map->m_llen - 1;
while ((cur >= end) && (cur < i_size_read(inode))) { while ((cur >= end) && (cur < i_size_read(inode))) {
pgoff_t index = cur >> PAGE_SHIFT; pgoff_t index = cur >> PAGE_SHIFT;
struct page *page; struct folio *folio;
page = erofs_grab_cache_page_nowait(inode->i_mapping, index); folio = erofs_grab_folio_nowait(inode->i_mapping, index);
if (page) { if (!IS_ERR_OR_NULL(folio)) {
if (PageUptodate(page)) if (folio_test_uptodate(folio))
unlock_page(page); folio_unlock(folio);
else else
z_erofs_scan_folio(f, page_folio(page), !!rac); z_erofs_scan_folio(f, folio, !!rac);
put_page(page); folio_put(folio);
} }
if (cur < PAGE_SIZE) if (cur < PAGE_SIZE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment