filemap: Convert filemap_get_pages to use folios

This saves a few calls to compound_head(), including one in
filemap_update_page().  Shrinks the kernel by 78 bytes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
This commit is contained in:
Matthew Wilcox (Oracle) 2021-03-10 14:01:22 -05:00
parent 81f4c03b7d
commit 65bca53b5f
1 changed files with 12 additions and 12 deletions

View File

@ -2422,9 +2422,8 @@ static bool filemap_range_uptodate(struct address_space *mapping,
static int filemap_update_page(struct kiocb *iocb,
struct address_space *mapping, struct iov_iter *iter,
struct page *page)
struct folio *folio)
{
struct folio *folio = page_folio(page);
int error;
if (iocb->ki_flags & IOCB_NOWAIT) {
@ -2521,13 +2520,14 @@ error:
}
static int filemap_readahead(struct kiocb *iocb, struct file *file,
struct address_space *mapping, struct page *page,
struct address_space *mapping, struct folio *folio,
pgoff_t last_index)
{
DEFINE_READAHEAD(ractl, file, &file->f_ra, mapping, folio->index);
if (iocb->ki_flags & IOCB_NOIO)
return -EAGAIN;
page_cache_async_readahead(mapping, &file->f_ra, file, page,
page->index, last_index - page->index);
page_cache_async_ra(&ractl, folio, last_index - folio->index);
return 0;
}
@ -2539,7 +2539,7 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
struct file_ra_state *ra = &filp->f_ra;
pgoff_t index = iocb->ki_pos >> PAGE_SHIFT;
pgoff_t last_index;
struct page *page;
struct folio *folio;
int err = 0;
last_index = DIV_ROUND_UP(iocb->ki_pos + iter->count, PAGE_SIZE);
@ -2565,16 +2565,16 @@ retry:
return err;
}
page = pvec->pages[pagevec_count(pvec) - 1];
if (PageReadahead(page)) {
err = filemap_readahead(iocb, filp, mapping, page, last_index);
folio = page_folio(pvec->pages[pagevec_count(pvec) - 1]);
if (folio_test_readahead(folio)) {
err = filemap_readahead(iocb, filp, mapping, folio, last_index);
if (err)
goto err;
}
if (!PageUptodate(page)) {
if (!folio_test_uptodate(folio)) {
if ((iocb->ki_flags & IOCB_WAITQ) && pagevec_count(pvec) > 1)
iocb->ki_flags |= IOCB_NOWAIT;
err = filemap_update_page(iocb, mapping, iter, page);
err = filemap_update_page(iocb, mapping, iter, folio);
if (err)
goto err;
}
@ -2582,7 +2582,7 @@ retry:
return 0;
err:
if (err < 0)
put_page(page);
folio_put(folio);
if (likely(--pvec->nr))
return 0;
if (err == AOP_TRUNCATED_PAGE)