From: Andreas Gruenbacher <agruenba@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: cluster-devel@redhat.com, Jan Kara <jack@suse.cz>,
Andreas Gruenbacher <agruenba@redhat.com>,
linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH v2 2/6] iomap: Fix iomap_dio_rw return value for page faults
Date: Mon, 19 Jul 2021 00:39:28 +0200 [thread overview]
Message-ID: <20210718223932.2703330-3-agruenba@redhat.com> (raw)
In-Reply-To: <20210718223932.2703330-1-agruenba@redhat.com>
When a page fault occurs during a direct I/O, iomap_dio_rw can currently return
0 when a page cannot be accessed. In that case, -EFAULT should be returned
instead. (For reads, a return value of 0 indicates the end of file.) Fix that
by casting the return value of iomap_apply from 0 to -EFAULT: in that position,
we know that we should have been able to read something.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/iomap/direct-io.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 9398b8c31323..a87a43ee8278 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -561,6 +561,8 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
ret = iomap_apply(inode, pos, count, iomap_flags, ops, dio,
iomap_dio_actor);
if (ret <= 0) {
+ if (ret == 0)
+ ret = -EFAULT;
/* magic error code to fall back to buffered I/O */
if (ret == -ENOTBLK) {
wait_for_completion = true;
--
2.26.3
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
next prev parent reply other threads:[~2021-07-18 22:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-18 22:39 [Ocfs2-devel] [PATCH v2 0/6] gfs2: Fix mmap + page fault deadlocks Andreas Gruenbacher
2021-07-18 22:39 ` [Ocfs2-devel] [PATCH v2 1/6] iov_iter: Introduce fault_in_iov_iter helper Andreas Gruenbacher
2021-07-19 19:26 ` Linus Torvalds
2021-07-18 22:39 ` Andreas Gruenbacher [this message]
2021-07-18 22:39 ` [Ocfs2-devel] [PATCH v2 3/6] gfs2: Add wrapper for iomap_file_buffered_write Andreas Gruenbacher
2021-07-18 22:39 ` [Ocfs2-devel] [PATCH v2 4/6] gfs2: Fix mmap + page fault deadlocks for buffered I/O Andreas Gruenbacher
2021-07-18 22:39 ` [Ocfs2-devel] [PATCH v2 5/6] iov_iter: Introduce ITER_FLAG_FAST_ONLY flag Andreas Gruenbacher
2021-07-19 19:29 ` Linus Torvalds
2021-07-19 20:17 ` Al Viro
2021-07-18 22:39 ` [Ocfs2-devel] [PATCH v2 6/6] gfs2: Fix mmap + page fault deadlocks for direct I/O Andreas Gruenbacher
2021-07-19 19:31 ` [Ocfs2-devel] [PATCH v2 0/6] gfs2: Fix mmap + page fault deadlocks Linus Torvalds
2021-07-19 20:14 ` Al Viro
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=20210718223932.2703330-3-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ocfs2-devel@oss.oracle.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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).