[PATCH 12/17] mm/filemap: Split filemap_readahead out of filemap_get_pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This simplifies the error handling.

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
 mm/filemap.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 81b569d818a3..7c6380a3a871 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2324,6 +2324,17 @@ static struct page *filemap_create_page(struct file *file,
 	return ERR_PTR(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, ra, filp, page,
+			pg_index, last_index - pg_index);
+	return 0;
+}
+
 static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
 		struct page **pages, unsigned int nr)
 {
@@ -2368,23 +2379,14 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
 				    (loff_t) pg_index << PAGE_SHIFT);
 		loff_t pg_count = iocb->ki_pos + iter->count - pg_pos;
 
-		if (PageReadahead(page)) {
-			if (iocb->ki_flags & IOCB_NOIO) {
-				put_page(page);
-				nr_got--;
-				err = -EAGAIN;
-				goto err;
-			}
-			page_cache_async_readahead(mapping, ra, filp, page,
-					pg_index, last_index - pg_index);
-		}
-
-		if (!PageUptodate(page)) {
+		if (PageReadahead(page))
+			err = filemap_readahead(iocb, filp, mapping, page,
+					last_index);
+		if (!err && !PageUptodate(page))
 			err = filemap_update_page(iocb, mapping, iter, page,
 					pg_pos, pg_count, nr_got == 1);
-			if (err)
-				nr_got--;
-		}
+		if (err)
+			nr_got--;
 	}
 
 err:
-- 
2.28.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux