public inbox for [email protected]
 help / color / mirror / Atom feed
From: Keith Busch <[email protected]>
To: <[email protected]>, <[email protected]>, <[email protected]>
Cc: Keith Busch <[email protected]>,
	Caleb Sander Mateos <[email protected]>
Subject: [PATCH] Revert "io_uring/rsrc: simplify the bvec iter count calculation"
Date: Mon, 10 Mar 2025 11:48:25 -0700	[thread overview]
Message-ID: <[email protected]> (raw)

From: Keith Busch <[email protected]>

This reverts commit 2a51c327d4a4a2eb62d67f4ea13a17efd0f25c5c.

The kernel registered bvecs do use the iov_iter_advance() API, so we
can't rely on this simplification anymore.

Fixes: 27cb27b6d5ea40 ("io_uring: add support for kernel registered bvecs")
Reported-by: Caleb Sander Mateos <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
---
 io_uring/rsrc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 5dd1e08275594..5fff6ba2b7c05 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1024,7 +1024,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
 	 * and advance us to the beginning.
 	 */
 	offset = buf_addr - imu->ubuf;
-	iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, len);
+	iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, offset + len);
 
 	if (offset) {
 		/*
@@ -1051,6 +1051,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
 		 * to use the slow iter advance.
 		 */
 		if (offset < bvec->bv_len) {
+			iter->count -= offset;
 			iter->iov_offset = offset;
 		} else if (imu->is_kbuf) {
 			iov_iter_advance(iter, offset);
@@ -1063,6 +1064,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
 
 			iter->bvec += seg_skip;
 			iter->nr_segs -= seg_skip;
+			iter->count -= bvec->bv_len + offset;
 			iter->iov_offset = offset & ((1UL << imu->folio_shift) - 1);
 		}
 	}
-- 
2.47.1


             reply	other threads:[~2025-03-10 18:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 18:48 Keith Busch [this message]
2025-03-10 18:50 ` [PATCH] Revert "io_uring/rsrc: simplify the bvec iter count calculation" Caleb Sander Mateos
2025-03-10 19:37 ` Jens Axboe

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox