From: Christoph Hellwig <hch@lst.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 09/13] mm: move putting the page on error out of filemap_make_page_uptodate
Date: Sat, 31 Oct 2020 10:00:00 +0100 [thread overview]
Message-ID: <20201031090004.452516-10-hch@lst.de> (raw)
In-Reply-To: <20201031090004.452516-1-hch@lst.de>
Move the put_page on error from filemap_make_page_uptodate into the
callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mm/filemap.c | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index 6089f1d9dd429f..5f4937715689e7 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2219,11 +2219,11 @@ static int filemap_make_page_uptodate(struct kiocb *iocb, struct iov_iter *iter,
loff_t last = iocb->ki_pos + iter->count;
pgoff_t last_index = (last + PAGE_SIZE - 1) >> PAGE_SHIFT;
loff_t pos = max(iocb->ki_pos, (loff_t)pg_index << PAGE_SHIFT);
- int error = -EAGAIN;
+ int error;
if (PageReadahead(page)) {
if (iocb->ki_flags & IOCB_NOIO)
- goto put_page;
+ return -EAGAIN;
page_cache_async_readahead(mapping, &file->f_ra, file, page,
pg_index, last_index - pg_index);
}
@@ -2232,7 +2232,7 @@ static int filemap_make_page_uptodate(struct kiocb *iocb, struct iov_iter *iter,
return 0;
if (iocb->ki_flags & IOCB_NOWAIT)
- goto put_page;
+ return -EAGAIN;
/*
* See comment in do_read_cache_page on why wait_on_page_locked is used
@@ -2240,13 +2240,13 @@ static int filemap_make_page_uptodate(struct kiocb *iocb, struct iov_iter *iter,
*/
if (iocb->ki_flags & IOCB_WAITQ) {
if (!first)
- goto put_page;
+ return -EAGAIN;
error = wait_on_page_locked_async(page, iocb->ki_waitq);
} else {
error = wait_on_page_locked_killable(page);
}
if (unlikely(error))
- goto put_page;
+ return error;
if (PageUptodate(page))
return 0;
@@ -2274,27 +2274,19 @@ static int filemap_make_page_uptodate(struct kiocb *iocb, struct iov_iter *iter,
/* Get exclusive access to the page ... */
error = lock_page_for_iocb(iocb, page);
if (unlikely(error))
- goto put_page;
+ return error;
page_not_up_to_date_locked:
/* Did it get truncated before we got the lock? */
if (!page->mapping) {
unlock_page(page);
- error = AOP_TRUNCATED_PAGE;
- goto put_page;
+ return AOP_TRUNCATED_PAGE;
}
/* Did somebody else fill it already? */
if (PageUptodate(page))
goto unlock_page;
- error = filemap_readpage(iocb, page);
- if (error)
- goto put_page;
- return 0;
-
-put_page:
- put_page(page);
- return error;
+ return filemap_readpage(iocb, page);
}
static int filemap_new_page(struct kiocb *iocb, struct iov_iter *iter,
@@ -2317,7 +2309,10 @@ static int filemap_new_page(struct kiocb *iocb, struct iov_iter *iter,
error = filemap_readpage(iocb, *page);
if (error)
goto put_page;
- return filemap_make_page_uptodate(iocb, iter, *page, index, true);
+ error = filemap_make_page_uptodate(iocb, iter, *page, index, true);
+ if (error)
+ goto put_page;
+ return 0;
put_page:
put_page(*page);
return error;
@@ -2360,7 +2355,7 @@ static int filemap_read_pages(struct kiocb *iocb, struct iov_iter *iter,
err = filemap_make_page_uptodate(iocb, iter, pages[i],
index + i, i == 0);
if (err) {
- for (j = i + 1; j < nr_pages; j++)
+ for (j = i; j < nr_pages; j++)
put_page(pages[j]);
nr_pages = i;
break;
--
2.28.0
next prev parent reply other threads:[~2020-10-31 9:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-31 8:59 clean up the generic pagecache read helpers Christoph Hellwig
2020-10-31 8:59 ` [PATCH 01/13] mm: simplify generic_file_buffered_read_readpage Christoph Hellwig
2020-10-31 8:59 ` [PATCH 02/13] mm: simplify generic_file_buffered_read_pagenotuptodate Christoph Hellwig
2020-10-31 8:59 ` [PATCH 03/13] mm: lift the nowait checks into generic_file_buffered_read_pagenotuptodate Christoph Hellwig
2020-10-31 8:59 ` [PATCH 04/13] mm: handle readahead in generic_file_buffered_read_pagenotuptodate Christoph Hellwig
2020-10-31 17:06 ` Matthew Wilcox
2020-11-01 10:31 ` Christoph Hellwig
2020-11-01 10:49 ` Matthew Wilcox
2020-11-01 10:51 ` Christoph Hellwig
2020-11-01 10:51 ` Christoph Hellwig
2020-11-01 11:04 ` Matthew Wilcox
2020-11-01 11:52 ` Christoph Hellwig
2020-11-01 14:55 ` Matthew Wilcox
2020-11-02 8:18 ` Christoph Hellwig
2020-10-31 8:59 ` [PATCH 05/13] mm: simplify generic_file_buffered_read_no_cached_page Christoph Hellwig
2020-10-31 16:20 ` Matthew Wilcox
2020-10-31 16:28 ` Matthew Wilcox
2020-11-01 10:29 ` Christoph Hellwig
2020-10-31 8:59 ` [PATCH 06/13] mm: factor out a filemap_find_get_pages helper Christoph Hellwig
2020-10-31 8:59 ` [PATCH 07/13] mm: refactor generic_file_buffered_read_get_pages Christoph Hellwig
2020-11-01 11:18 ` Matthew Wilcox
2020-10-31 8:59 ` [PATCH 08/13] mm: move putting the page on error out of filemap_readpage Christoph Hellwig
2020-10-31 9:00 ` Christoph Hellwig [this message]
2020-10-31 9:00 ` [PATCH 10/13] mm: open code readahead in filemap_new_page Christoph Hellwig
2020-11-01 11:20 ` Matthew Wilcox
2020-10-31 9:00 ` [PATCH 11/13] mm: streamline the partially uptodate checks in filemap_make_page_uptodate Christoph Hellwig
2020-11-01 11:23 ` Matthew Wilcox
2020-10-31 9:00 ` [PATCH 12/13] mm: rename generic_file_buffered_read to filemap_read Christoph Hellwig
2020-10-31 9:00 ` [PATCH 13/13] mm: simplify generic_file_read_iter Christoph Hellwig
2020-10-31 15:42 ` clean up the generic pagecache read helpers Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201031090004.452516-10-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=kent.overstreet@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).