Skip to content

Commit

Permalink
io_uring/rsrc: simplify the bvec iter count calculation
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Link: https://lore.kernel.org/r/20250103150412.12549-1-minhquangbui99@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Bui Quang Minh authored and Jens Axboe committed Jan 3, 2025
1 parent d62c2f0 commit 2a51c32
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions io_uring/rsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,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) {
/*
Expand All @@ -904,7 +904,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;
Expand All @@ -915,7 +914,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);
}
}
Expand Down

0 comments on commit 2a51c32

Please sign in to comment.