From: Pavel Begunkov <asml.silence@gmail.com>
To: stable@vger.kernel.org
Cc: Muhammad Ramdhan <ramdhan@starlabs.sg>,
Bing-Jhong Billy Jheng <billy@starlabs.sg>,
Jacob Soo <jacob.soo@starlabs.sg>, Jens Axboe <axboe@kernel.dk>,
Pavel Begunkov <asml.silence@gmail.com>
Subject: [PATCH stable-6.1 3/3] io_uring/rw: commit provided buffer state on async
Date: Mon, 10 Feb 2025 17:27:56 +0000 [thread overview]
Message-ID: <71404cdcc823638709aa44ee2137cd444fc708ad.1739208415.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1739208415.git.asml.silence@gmail.com>
[ upstream commit d63b0e8a628e62ca85a0f7915230186bb92f8bb4 ]
When we get -EIOCBQUEUED, we need to ensure that the buffer is consumed
from the provided buffer ring, which can be done with io_kbuf_recycle()
+ REQ_F_PARTIAL_IO.
Reported-by: Muhammad Ramdhan <ramdhan@starlabs.sg>
Reported-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
Reported-by: Jacob Soo <jacob.soo@starlabs.sg>
Fixes: c7fb19428d67d ("io_uring: add support for ring mapped supplied buffers")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/rw.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 692663bd864f..b75f62dccce6 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -772,6 +772,8 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags)
goto done;
ret = 0;
} else if (ret == -EIOCBQUEUED) {
+ req->flags |= REQ_F_PARTIAL_IO;
+ io_kbuf_recycle(req, issue_flags);
if (iovec)
kfree(iovec);
return IOU_ISSUE_SKIP_COMPLETE;
@@ -795,6 +797,9 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags)
goto done;
}
+ req->flags |= REQ_F_PARTIAL_IO;
+ io_kbuf_recycle(req, issue_flags);
+
io = req->async_data;
s = &io->s;
/*
@@ -935,6 +940,11 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
else
ret2 = -EINVAL;
+ if (ret2 == -EIOCBQUEUED) {
+ req->flags |= REQ_F_PARTIAL_IO;
+ io_kbuf_recycle(req, issue_flags);
+ }
+
if (req->flags & REQ_F_REISSUE) {
req->flags &= ~REQ_F_REISSUE;
ret2 = -EAGAIN;
--
2.48.1
prev parent reply other threads:[~2025-02-10 17:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 17:27 [PATCH stable-6.1 0/3] provided buffer recycling fixes Pavel Begunkov
2025-02-10 17:27 ` [PATCH stable-6.1 1/3] io_uring: fix multishots with selected buffers Pavel Begunkov
2025-02-10 17:27 ` [PATCH stable-6.1 2/3] io_uring: fix io_req_prep_async with provided buffers Pavel Begunkov
2025-02-10 17:27 ` Pavel Begunkov [this message]
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=71404cdcc823638709aa44ee2137cd444fc708ad.1739208415.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=billy@starlabs.sg \
--cc=jacob.soo@starlabs.sg \
--cc=ramdhan@starlabs.sg \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.