filemap: Convert filemap_read_page to take a folio

One of the callers already had a folio; the other two grow by a few
bytes, but filemap_read_page() shrinks by 50 bytes for a net reduction
of 27 bytes.
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 e1c37722
...@@ -2369,8 +2369,8 @@ static void filemap_get_read_batch(struct address_space *mapping, ...@@ -2369,8 +2369,8 @@ static void filemap_get_read_batch(struct address_space *mapping,
rcu_read_unlock(); rcu_read_unlock();
} }
static int filemap_read_page(struct file *file, struct address_space *mapping, static int filemap_read_folio(struct file *file, struct address_space *mapping,
struct page *page) struct folio *folio)
{ {
int error; int error;
...@@ -2379,16 +2379,16 @@ static int filemap_read_page(struct file *file, struct address_space *mapping, ...@@ -2379,16 +2379,16 @@ static int filemap_read_page(struct file *file, struct address_space *mapping,
* eg. multipath errors. PG_error will be set again if readpage * eg. multipath errors. PG_error will be set again if readpage
* fails. * fails.
*/ */
ClearPageError(page); folio_clear_error(folio);
/* Start the actual read. The read will unlock the page. */ /* Start the actual read. The read will unlock the page. */
error = mapping->a_ops->readpage(file, page); error = mapping->a_ops->readpage(file, &folio->page);
if (error) if (error)
return error; return error;
error = wait_on_page_locked_killable(page); error = folio_wait_locked_killable(folio);
if (error) if (error)
return error; return error;
if (PageUptodate(page)) if (folio_test_uptodate(folio))
return 0; return 0;
shrink_readahead_size_eio(&file->f_ra); shrink_readahead_size_eio(&file->f_ra);
return -EIO; return -EIO;
...@@ -2464,7 +2464,7 @@ static int filemap_update_page(struct kiocb *iocb, ...@@ -2464,7 +2464,7 @@ static int filemap_update_page(struct kiocb *iocb,
if (iocb->ki_flags & (IOCB_NOIO | IOCB_NOWAIT | IOCB_WAITQ)) if (iocb->ki_flags & (IOCB_NOIO | IOCB_NOWAIT | IOCB_WAITQ))
goto unlock; goto unlock;
error = filemap_read_page(iocb->ki_filp, mapping, &folio->page); error = filemap_read_folio(iocb->ki_filp, mapping, folio);
goto unlock_mapping; goto unlock_mapping;
unlock: unlock:
folio_unlock(folio); folio_unlock(folio);
...@@ -2506,7 +2506,7 @@ static int filemap_create_page(struct file *file, ...@@ -2506,7 +2506,7 @@ static int filemap_create_page(struct file *file,
if (error) if (error)
goto error; goto error;
error = filemap_read_page(file, mapping, page); error = filemap_read_folio(file, mapping, page_folio(page));
if (error) if (error)
goto error; goto error;
...@@ -3168,7 +3168,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) ...@@ -3168,7 +3168,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
* and we need to check for errors. * and we need to check for errors.
*/ */
fpin = maybe_unlock_mmap_for_io(vmf, fpin); fpin = maybe_unlock_mmap_for_io(vmf, fpin);
error = filemap_read_page(file, mapping, page); error = filemap_read_folio(file, mapping, page_folio(page));
if (fpin) if (fpin)
goto out_retry; goto out_retry;
put_page(page); put_page(page);
......
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