lkml.org 
[lkml]   [2021]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v5 14/18] mm/filemap: Split filemap_readahead out of filemap_get_pages
Date
This simplifies the error handling.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
mm/filemap.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index a3ebc6082022e..ba20baef9056c 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2342,6 +2342,17 @@ static int filemap_create_page(struct file *file,
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)
{
@@ -2379,17 +2390,15 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
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)) {
--
2.29.2
\
 
 \ /
  Last update: 2021-01-22 18:52    [W:0.096 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site