]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
io_uring: remove nr_segs recalculation in io_import_kbuf()
authorMing Lei <ming.lei@redhat.com>
Wed, 31 Dec 2025 03:00:57 +0000 (11:00 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Jan 2026 15:06:33 +0000 (08:06 -0700)
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>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rsrc.c

index 41c89f5c616da2cc17e5e76ef2842483ecf9de07..ee6283676ba7c0f657b737ebb88cd510e0d127e9 100644 (file)
@@ -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;
 }