From: Andreas Gruenbacher Date: Mon, 19 Jul 2021 00:39:28 +0200 Subject: [Cluster-devel] [PATCH v2 2/6] iomap: Fix iomap_dio_rw return value for page faults In-Reply-To: <20210718223932.2703330-1-agruenba@redhat.com> References: <20210718223932.2703330-1-agruenba@redhat.com> Message-ID: <20210718223932.2703330-3-agruenba@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- 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