io_uring/rw: treat -EOPNOTSUPP for IOCB_NOWAIT like -EAGAIN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jens Axboe <axboe@xxxxxxxxx>

commit c0a9d496e0fece67db777bd48550376cf2960c47 upstream.

Some file systems, ocfs2 in this case, will return -EOPNOTSUPP for
an IOCB_NOWAIT read/write attempt. While this can be argued to be
correct, the usual return value for something that requires blocking
issue is -EAGAIN.

A refactoring io_uring commit dropped calling kiocb_done() for
negative return values, which is otherwise where we already do that
transformation. To ensure we catch it in both spots, check it in
__io_read() itself as well.

Reported-by: Robert Sander <r.sander@xxxxxxxxxxxxxxxxxxx>
Link: https://fosstodon.org/@gurubert@xxxxxxxxxxxxxxxxxxxx/113112431889638440
Cc: stable@xxxxxxxxxxxxxxx
Fixes: a08d195b586a ("io_uring/rw: split io_read() into a helper")
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 io_uring/rw.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -855,6 +855,14 @@ static int __io_read(struct io_kiocb *re
 
 	ret = io_iter_do_read(rw, &io->iter);
 
+	/*
+	 * Some file systems like to return -EOPNOTSUPP for an IOCB_NOWAIT
+	 * issue, even though they should be returning -EAGAIN. To be safe,
+	 * retry from blocking context for either.
+	 */
+	if (ret == -EOPNOTSUPP && force_nonblock)
+		ret = -EAGAIN;
+
 	if (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) {
 		req->flags &= ~REQ_F_REISSUE;
 		/* If we can poll, just do that. */


Patches currently in stable-queue which might be from axboe@xxxxxxxxx are

queue-6.11/nbd-correct-the-maximum-value-for-discard-sectors.patch
queue-6.11/block-bfq-fix-possible-uaf-for-bfqq-bic-with-merge-c.patch
queue-6.11/io_uring-rw-treat-eopnotsupp-for-iocb_nowait-like-eagain.patch
queue-6.11/io_uring-io-wq-do-not-allow-pinning-outside-of-cpuse.patch
queue-6.11/nbd-fix-race-between-timeout-and-normal-completion.patch
queue-6.11/block-bfq-fix-uaf-for-accessing-waker_bfqq-after-spl.patch
queue-6.11/block-bfq-choose-the-last-bfqq-from-merge-chain-in-b.patch
queue-6.11/ublk-move-zone-report-data-out-of-request-pdu.patch
queue-6.11/lib-sbitmap-define-swap_lock-as-raw_spinlock_t.patch
queue-6.11/block-bfq-don-t-break-merge-chain-in-bfq_split_bfqq.patch
queue-6.11/block-fix-potential-invalid-pointer-dereference-in-b.patch
queue-6.11/io_uring-check-for-presence-of-task_work-rather-than-tif_notify_signal.patch
queue-6.11/io_uring-sqpoll-do-not-allow-pinning-outside-of-cpuset.patch
queue-6.11/block-bfq-fix-procress-reference-leakage-for-bfqq-in.patch
queue-6.11/io_uring-io-wq-inherit-cpuset-of-cgroup-in-io-worker.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux