Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "io_uring/rsrc: simplify the bvec iter count calculation"

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 <csander@purestorage.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://lore.kernel.org/r/20250310184825.569371-1-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Keith Busch and committed by
Jens Axboe
334f795f 390174c9

+3 -1
+3 -1
io_uring/rsrc.c
··· 1024 1024 * and advance us to the beginning. 1025 1025 */ 1026 1026 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); 1028 1028 1029 1029 if (offset) { 1030 1030 /* ··· 1051 1051 * to use the slow iter advance. 1052 1052 */ 1053 1053 if (offset < bvec->bv_len) { 1054 + iter->count -= offset; 1054 1055 iter->iov_offset = offset; 1055 1056 } else if (imu->is_kbuf) { 1056 1057 iov_iter_advance(iter, offset); ··· 1064 1063 1065 1064 iter->bvec += seg_skip; 1066 1065 iter->nr_segs -= seg_skip; 1066 + iter->count -= bvec->bv_len + offset; 1067 1067 iter->iov_offset = offset & ((1UL << imu->folio_shift) - 1); 1068 1068 } 1069 1069 }