Skip to content

Commit 334f795

Browse files
keithbuschaxboe
authored andcommitted
Revert "io_uring/rsrc: simplify the bvec iter count calculation"
This reverts commit 2a51c32. The kernel registered bvecs do use the iov_iter_advance() API, so we can't rely on this simplification anymore. Fixes: 27cb27b ("io_uring: add support for kernel registered bvecs") Reported-by: Caleb Sander Mateos <[email protected]> Signed-off-by: Keith Busch <[email protected]> Reviewed-by: Caleb Sander Mateos <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 390174c commit 334f795

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

io_uring/rsrc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10241024
* and advance us to the beginning.
10251025
*/
10261026
offset = buf_addr - imu->ubuf;
1027-
iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, len);
1027+
iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, offset + len);
10281028

10291029
if (offset) {
10301030
/*
@@ -1051,6 +1051,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10511051
* to use the slow iter advance.
10521052
*/
10531053
if (offset < bvec->bv_len) {
1054+
iter->count -= offset;
10541055
iter->iov_offset = offset;
10551056
} else if (imu->is_kbuf) {
10561057
iov_iter_advance(iter, offset);
@@ -1063,6 +1064,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10631064

10641065
iter->bvec += seg_skip;
10651066
iter->nr_segs -= seg_skip;
1067+
iter->count -= bvec->bv_len + offset;
10661068
iter->iov_offset = offset & ((1UL << imu->folio_shift) - 1);
10671069
}
10681070
}

0 commit comments

Comments
 (0)