summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2022-05-22 20:05:39 -0600
committerJens Axboe <axboe@kernel.dk>2022-08-13 21:04:15 -0600
commit884a90ca0a7b57ca8d374629e335ca49a3054592 (patch)
tree7cb61321ee33037ad93702657e70508a0feff9aa
parente47780044579f9d1baf539c45b392af0401bc496 (diff)
io_uring: use ubuf for single range imports for read/writeio_uring-iter
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/rw.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 1babd77da79c..0881e0ca0db0 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -377,7 +377,7 @@ static struct iovec *__io_import_iovec(int ddir, struct io_kiocb *req,
rw->len = sqe_len;
}
- ret = import_single_range(ddir, buf, sqe_len, s->fast_iov, iter);
+ ret = import_ubuf(ddir, buf, sqe_len, iter);
if (ret)
return ERR_PTR(ret);
return NULL;
@@ -388,7 +388,7 @@ static struct iovec *__io_import_iovec(int ddir, struct io_kiocb *req,
ret = io_iov_buffer_select(req, iovec, issue_flags);
if (ret)
return ERR_PTR(ret);
- iov_iter_init(iter, ddir, iovec, 1, iovec->iov_len);
+ iov_iter_ubuf(iter, ddir, iovec[0].iov_base, iovec[0].iov_len);
return NULL;
}
@@ -444,7 +444,10 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
struct iovec iovec;
ssize_t nr;
- if (!iov_iter_is_bvec(iter)) {
+ if (iter_is_ubuf(iter)) {
+ iovec.iov_base = iter->ubuf + iter->iov_offset;
+ iovec.iov_len = iter->count - iter->iov_offset;
+ } else if (!iov_iter_is_bvec(iter)) {
iovec = iov_iter_iovec(iter);
} else {
iovec.iov_base = u64_to_user_ptr(rw->addr);
@@ -465,7 +468,7 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
break;
}
ret += nr;
- if (!iov_iter_is_bvec(iter)) {
+ if (iter_is_ubuf(iter) || !iov_iter_is_bvec(iter)) {
iov_iter_advance(iter, nr);
} else {
rw->addr += nr;
@@ -489,7 +492,7 @@ static void io_req_map_rw(struct io_kiocb *req, const struct iovec *iovec,
io->free_iovec = iovec;
io->bytes_done = 0;
/* can only be fixed buffers, no need to do anything */
- if (iov_iter_is_bvec(iter))
+ if (iov_iter_is_bvec(iter) || iter_is_ubuf(iter))
return;
if (!iovec) {
unsigned iov_off = 0;