summaryrefslogtreecommitdiff
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2021-02-24 12:02:32 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2021-02-24 13:38:28 -0800
commit5963fe031638bb812c49ddf5adcdc783a57430f7 (patch)
treebcdef091ed75fe0dfb9378048fca68c4076c3e80 /mm/filemap.c
parentfce70da3a80fcd0a9c0192dedd6bf86a43845ac9 (diff)
mm/filemap: split filemap_readahead out of filemap_get_pages
This simplifies the error handling. Link: https://lkml.kernel.org/r/20210122160140.223228-15-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 1eaafc9402e0..f8181beded38 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2330,6 +2330,17 @@ error:
return error;
}
+static int filemap_readahead(struct kiocb *iocb, struct file *file,
+ struct address_space *mapping, struct page *page,
+ pgoff_t last_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);
+ return 0;
+}
+
static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
struct pagevec *pvec)
{
@@ -2367,17 +2378,15 @@ find_page:
got_pages:
{
struct page *page = pvec->pages[pvec->nr - 1];
- pgoff_t pg_index = page->index;
if (PageReadahead(page)) {
- if (iocb->ki_flags & IOCB_NOIO) {
+ err = filemap_readahead(iocb, filp, mapping, page,
+ last_index);
+ if (err) {
put_page(page);
pvec->nr--;
- err = -EAGAIN;
goto err;
}
- page_cache_async_readahead(mapping, ra, filp, page,
- pg_index, last_index - pg_index);
}
if (!PageUptodate(page)) {