Skip to content

Commit 3d3d1c6

Browse files
Ming Leikawasaki
authored andcommitted
io_uring: remove nr_segs recalculation in io_import_kbuf()
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 <[email protected]> Reviewed-by: Nitesh Shetty <[email protected]>
1 parent c782ee3 commit 3d3d1c6

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

io_uring/rsrc.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,17 +1055,6 @@ static int io_import_kbuf(int ddir, struct iov_iter *iter,
10551055

10561056
iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, count);
10571057
iov_iter_advance(iter, offset);
1058-
1059-
if (count < imu->len) {
1060-
const struct bio_vec *bvec = iter->bvec;
1061-
1062-
len += iter->iov_offset;
1063-
while (len > bvec->bv_len) {
1064-
len -= bvec->bv_len;
1065-
bvec++;
1066-
}
1067-
iter->nr_segs = 1 + bvec - iter->bvec;
1068-
}
10691058
return 0;
10701059
}
10711060

0 commit comments

Comments
 (0)