linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: [PATCH 2/2] fs: Make mpage_readpage synchronous
Date: Fri, 16 Oct 2020 17:14:26 +0100	[thread overview]
Message-ID: <20201016161426.21715-3-willy@infradead.org> (raw)
In-Reply-To: <20201016161426.21715-1-willy@infradead.org>

A synchronous readpage lets us report the actual errno instead of
ineffectively setting PageError.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/mpage.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/fs/mpage.c b/fs/mpage.c
index 830e6cc2a9e7..88aba79a1861 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -406,11 +406,30 @@ int mpage_readpage(struct page *page, get_block_t get_block)
 		.nr_pages = 1,
 		.get_block = get_block,
 	};
+	int err;
 
 	args.bio = do_mpage_readpage(&args);
-	if (args.bio)
-		mpage_bio_submit(REQ_OP_READ, 0, args.bio);
-	return 0;
+	/*
+	 * XXX: We can't tell the difference between "fell back to
+	 * block_read_full_page" and "this was a hole".  If we could,
+	 * we'd avoid unlocking the page in do_mpage_readpage() and
+	 * return AOP_UPDATED_PAGE here.
+	 */
+	if (!args.bio)
+		return 0;
+	bio_set_op_attrs(args.bio, REQ_OP_READ, 0);
+	guard_bio_eod(args.bio);
+	err = submit_bio_killable(args.bio, mpage_end_io);
+	if (unlikely(err))
+		goto err;
+
+	SetPageUptodate(page);
+	return AOP_UPDATED_PAGE;
+
+err:
+	if (err != -ERESTARTSYS)
+		unlock_page(page);
+	return err;
 }
 EXPORT_SYMBOL(mpage_readpage);
 
-- 
2.28.0


  parent reply	other threads:[~2020-10-16 16:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 16:14 [PATCH 0/2] Killable synchronous BIO submission Matthew Wilcox (Oracle)
2020-10-16 16:14 ` [PATCH 1/2] block: Add submit_bio_killable Matthew Wilcox (Oracle)
2020-10-16 16:14 ` Matthew Wilcox (Oracle) [this message]
2020-10-16 16:56   ` [PATCH 2/2] fs: Make mpage_readpage synchronous Keith Busch
2020-10-16 16:59     ` 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=20201016161426.21715-3-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.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).