Commit 3a712808 authored by Jens Axboe's avatar Jens Axboe Committed by Wen Zhiwei
Browse files

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

stable inclusion
from stable-v6.6.68
commit 41928840172e0755509da4641955d477612f6781
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBMDV1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=41928840172e0755509da4641955d477612f6781



--------------------------------

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: default avatarRobert Sander <r.sander@heinlein-support.de>
Link: https://fosstodon.org/@gurubert@mastodon.gurubert.de/113112431889638440


Cc: stable@vger.kernel.org
Fixes: a08d195b586a ("io_uring/rw: split io_read() into a helper")
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent c0f45be5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -778,6 +778,14 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags)

	ret = io_iter_do_read(rw, &s->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 */