linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring: do not recycle buffer in READV
@ 2022-07-21 13:13 Dylan Yudaken
  2022-07-21 14:31 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Dylan Yudaken @ 2022-07-21 13:13 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring
  Cc: Kernel-team, linux-kernel, Dylan Yudaken, Ammar Faizi

READV cannot recycle buffers as it would lose some of the data required to
reimport that buffer.

Reported-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Fixes: b66e65f41426 ("io_uring: never call io_buffer_select() for a buffer re-select")
Signed-off-by: Dylan Yudaken <dylany@fb.com>
---

I think going forward we can probably re-enable recycling for READV, or perhaps stick
it in the opdef to make it a bit more general. However since it is late in the merge
cycle I thought the simplest approach is best.

Worth noting the initial discussed approach of stashing the data in `struct io_rw` would not
have worked as that struct is full already apparently.

Dylan

 fs/io_uring.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index a01ea49f3017..b0180679584f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1737,6 +1737,14 @@ static void io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
 	    (req->flags & REQ_F_PARTIAL_IO))
 		return;
 
+	/*
+	 * READV uses fields in `struct io_rw` (len/addr) to stash the selected
+	 * buffer data. However if that buffer is recycled the original request
+	 * data stored in addr is lost. Therefore forbid recycling for now.
+	 */
+	if (req->opcode == IORING_OP_READV)
+		return;
+
 	/*
 	 * We don't need to recycle for REQ_F_BUFFER_RING, we can just clear
 	 * the flag and hence ensure that bl->head doesn't get incremented.

base-commit: ff6992735ade75aae3e35d16b17da1008d753d28
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io_uring: do not recycle buffer in READV
  2022-07-21 13:13 [PATCH] io_uring: do not recycle buffer in READV Dylan Yudaken
@ 2022-07-21 14:31 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-07-21 14:31 UTC (permalink / raw)
  To: asml.silence, dylany, io-uring; +Cc: linux-kernel, Kernel-team, ammarfaizi2

On Thu, 21 Jul 2022 06:13:25 -0700, Dylan Yudaken wrote:
> READV cannot recycle buffers as it would lose some of the data required to
> reimport that buffer.
> 
> 

Applied, thanks!

[1/1] io_uring: do not recycle buffer in READV
      commit: 934447a603b22d98f45a679115d8402e1efdd0f7

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-21 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 13:13 [PATCH] io_uring: do not recycle buffer in READV Dylan Yudaken
2022-07-21 14:31 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).