From: Matthew Wilcox <willy@infradead.org>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: filemap_fault can lose errors
Date: Tue, 10 Sep 2019 19:51:58 -0700 [thread overview]
Message-ID: <20190911025158.GG29434@bombadil.infradead.org> (raw)
If we encounter an error on a page, we can lose the error if we've
dropped the mmap_sem while we wait for the I/O. That can result in
taking the fault multiple times, and retrying the read multiple times.
Spotted by inspection.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Fixes: 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operations")
diff --git a/mm/filemap.c b/mm/filemap.c
index d0cf700bf201..37bd4aedfccf 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2615,6 +2615,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
if (!PageUptodate(page))
error = -EIO;
}
+ if (error < 0)
+ ret |= VM_FAULT_SIGBUS;
if (fpin)
goto out_retry;
put_page(page);
@@ -2622,9 +2624,9 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
if (!error || error == AOP_TRUNCATED_PAGE)
goto retry_find;
- /* Things didn't work out. Return zero to tell the mm layer so. */
+ /* Things didn't work out. */
shrink_readahead_size_eio(file, ra);
- return VM_FAULT_SIGBUS;
+ return ret;
out_retry:
/*
next reply other threads:[~2019-09-11 2:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 2:51 Matthew Wilcox [this message]
2019-09-11 15:23 ` filemap_fault can lose errors Kirill A. Shutemov
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=20190911025158.GG29434@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.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).