UPSTREAM: iomap: Support partial direct I/O on user copy failures
commit 97308f8b0d867e9ef59528cd97f0db55ffdf5651 upstream
In iomap_dio_rw, when iomap_apply returns an -EFAULT error and the
IOMAP_DIO_PARTIAL flag is set, complete the request synchronously and
return a partial result. This allows the caller to deal with the page
fault and retry the remainder of the request.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit ea7a578588
)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5de5ec3e55f18305f76e78ab4c72ce3ee1272522
This commit is contained in:
parent
89f91db7ae
commit
18e16d6365
|
@ -600,6 +600,12 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
|
|||
if (iov_iter_rw(iter) == READ && iomi.pos >= dio->i_size)
|
||||
iov_iter_revert(iter, iomi.pos - dio->i_size);
|
||||
|
||||
if (ret == -EFAULT && dio->size && (dio_flags & IOMAP_DIO_PARTIAL)) {
|
||||
if (!(iocb->ki_flags & IOCB_NOWAIT))
|
||||
wait_for_completion = true;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
/* magic error code to fall back to buffered I/O */
|
||||
if (ret == -ENOTBLK) {
|
||||
wait_for_completion = true;
|
||||
|
|
|
@ -332,6 +332,13 @@ struct iomap_dio_ops {
|
|||
*/
|
||||
#define IOMAP_DIO_OVERWRITE_ONLY (1 << 1)
|
||||
|
||||
/*
|
||||
* When a page fault occurs, return a partial synchronous result and allow
|
||||
* the caller to retry the rest of the operation after dealing with the page
|
||||
* fault.
|
||||
*/
|
||||
#define IOMAP_DIO_PARTIAL (1 << 2)
|
||||
|
||||
ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
|
||||
const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
|
||||
unsigned int dio_flags, size_t done_before);
|
||||
|
|
Loading…
Reference in New Issue