filemap: Use folios in next_uptodate_page

This saves 105 bytes of text.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarWilliam Kucharski <william.kucharski@oracle.com>
parent 1afd7ae5
...@@ -3227,43 +3227,43 @@ static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) ...@@ -3227,43 +3227,43 @@ static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page)
return false; return false;
} }
static struct page *next_uptodate_page(struct page *page, static struct page *next_uptodate_page(struct folio *folio,
struct address_space *mapping, struct address_space *mapping,
struct xa_state *xas, pgoff_t end_pgoff) struct xa_state *xas, pgoff_t end_pgoff)
{ {
unsigned long max_idx; unsigned long max_idx;
do { do {
if (!page) if (!folio)
return NULL; return NULL;
if (xas_retry(xas, page)) if (xas_retry(xas, folio))
continue; continue;
if (xa_is_value(page)) if (xa_is_value(folio))
continue; continue;
if (PageLocked(page)) if (folio_test_locked(folio))
continue; continue;
if (!page_cache_get_speculative(page)) if (!folio_try_get_rcu(folio))
continue; continue;
/* Has the page moved or been split? */ /* Has the page moved or been split? */
if (unlikely(page != xas_reload(xas))) if (unlikely(folio != xas_reload(xas)))
goto skip; goto skip;
if (!PageUptodate(page) || PageReadahead(page)) if (!folio_test_uptodate(folio) || folio_test_readahead(folio))
goto skip; goto skip;
if (!trylock_page(page)) if (!folio_trylock(folio))
goto skip; goto skip;
if (page->mapping != mapping) if (folio->mapping != mapping)
goto unlock; goto unlock;
if (!PageUptodate(page)) if (!folio_test_uptodate(folio))
goto unlock; goto unlock;
max_idx = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE); max_idx = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE);
if (xas->xa_index >= max_idx) if (xas->xa_index >= max_idx)
goto unlock; goto unlock;
return page; return &folio->page;
unlock: unlock:
unlock_page(page); folio_unlock(folio);
skip: skip:
put_page(page); folio_put(folio);
} while ((page = xas_next_entry(xas, end_pgoff)) != NULL); } while ((folio = xas_next_entry(xas, end_pgoff)) != NULL);
return NULL; return NULL;
} }
......
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