From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: io-uring@vger.kernel.org,
Caleb Sander Mateos <csander@purestorage.com>,
Nitesh Shetty <nj.shetty@samsung.com>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH V2 3/3] io_uring: remove nr_segs recalculation in io_import_kbuf()
Date: Wed, 31 Dec 2025 11:00:57 +0800 [thread overview]
Message-ID: <20251231030101.3093960-4-ming.lei@redhat.com> (raw)
In-Reply-To: <20251231030101.3093960-1-ming.lei@redhat.com>
io_import_kbuf() recalculates iter->nr_segs to reflect only the bvecs
needed for the requested byte range. This was added to provide an
accurate segment count to bio_iov_bvec_set(), which copied nr_segs to
bio->bi_vcnt for use as a bio split hint.
The previous two patches eliminated this dependency:
- bio_may_need_split() now uses bi_iter instead of bi_vcnt for split
decisions
- bio_iov_bvec_set() no longer copies nr_segs to bi_vcnt
Since nr_segs is no longer used for bio split decisions, the
recalculation loop is unnecessary. The iov_iter already has the correct
bi_size to cap iteration, so an oversized nr_segs is harmless.
Link: https://lkml.org/lkml/2025/4/16/351
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
io_uring/rsrc.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 41c89f5c616d..ee6283676ba7 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1055,17 +1055,6 @@ static int io_import_kbuf(int ddir, struct iov_iter *iter,
iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, count);
iov_iter_advance(iter, offset);
-
- if (count < imu->len) {
- const struct bio_vec *bvec = iter->bvec;
-
- len += iter->iov_offset;
- while (len > bvec->bv_len) {
- len -= bvec->bv_len;
- bvec++;
- }
- iter->nr_segs = 1 + bvec - iter->bvec;
- }
return 0;
}
--
2.47.0
next prev parent reply other threads:[~2025-12-31 3:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 3:00 [PATCH V2 0/3] block: avoid to use bi_vcnt in bio_may_need_split() Ming Lei
2025-12-31 3:00 ` [PATCH V2 1/3] block: use bvec iterator helper for bio_may_need_split() Ming Lei
2026-01-07 10:38 ` Nitesh Shetty
2025-12-31 3:00 ` [PATCH V2 2/3] block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set() Ming Lei
2026-01-07 10:39 ` Nitesh Shetty
2025-12-31 3:00 ` Ming Lei [this message]
2026-01-07 10:40 ` [PATCH V2 3/3] io_uring: remove nr_segs recalculation in io_import_kbuf() Nitesh Shetty
2026-01-07 4:11 ` [PATCH V2 0/3] block: avoid to use bi_vcnt in bio_may_need_split() Ming Lei
2026-01-07 15:08 ` 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 \
--in-reply-to=20251231030101.3093960-4-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=nj.shetty@samsung.com \
/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