Commit 334f795f authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe
Browse files

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



This reverts commit 2a51c327.

The kernel registered bvecs do use the iov_iter_advance() API, so we
can't rely on this simplification anymore.

Fixes: 27cb27b6 ("io_uring: add support for kernel registered bvecs")
Reported-by: default avatarCaleb Sander Mateos <csander@purestorage.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarCaleb Sander Mateos <csander@purestorage.com>
Link: https://lore.kernel.org/r/20250310184825.569371-1-kbusch@meta.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 390174c9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1024,7 +1024,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
	 * and advance us to the beginning.
	 */
	offset = buf_addr - imu->ubuf;
	iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, len);
	iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, offset + len);

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

			iter->bvec += seg_skip;
			iter->nr_segs -= seg_skip;
			iter->count -= bvec->bv_len + offset;
			iter->iov_offset = offset & ((1UL << imu->folio_shift) - 1);
		}
	}