Skip to contentSkip to conversation

io_uring/rsrc: simplify the bvec iter's count calculation

PATCH Applied Bui Quang Minh 2 participants 2 messages Jan 3, 2025 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring/rsrc: simplify the bvec iter's count calculation

As we don't use iov_iter_advance() but our own logic in io_import_fixed(), we can remove the logic that over-sets the iter's count to len + offset then adjusts it later to len. This helps to make the code cleaner.

---
 io_uring/rsrc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
io_uring/rsrc.c +1 -3
index 077f84684c18..d0d6ee85f32b 100644
@@ -883,7 +883,7 @@ 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, offset + len);
+	iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, len);
 
 	if (offset) {
 		/*
@@ -905,7 +905,6 @@ int io_import_fixed(int ddir, struct iov_iter *iter,
 		const struct bio_vec *bvec = imu->bvec;
 
 		if (offset < bvec->bv_len) {
-			iter->count -= offset;
 			iter->iov_offset = offset;
 		} else {
 			unsigned long seg_skip;
@@ -916,7 +915,6 @@ 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);
 		}
 	}
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Bui Quang Minh

As we don't use iov_iter_advance() but our own logic in io_import_fixed(), we can remove the logic that over-sets the iter's count to len + offset then adjusts it later to len. This helps to make the code cleaner.

Applied, thanks!

[1/1] io_uring/rsrc: simplify the bvec iter's count calculation

      commit: 2a51c327d4a4a2eb62d67f4ea13a17efd0f25c5c

Best regards,

Signature · 1 line
Jens Axboe