Skip to content

Commit 45097da

Browse files
Xiaoguang Wangaxboe
authored andcommitted
io_uring: do not always copy iovec in io_req_map_rw()
In io_read_prep() or io_write_prep(), io_req_map_rw() takes struct io_async_rw's fast_iov as argument to call io_import_iovec(), and if io_import_iovec() uses struct io_async_rw's fast_iov as valid iovec array, later indeed io_req_map_rw() does not need to do the memcpy operation, because they are same pointers. Signed-off-by: Xiaoguang Wang <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 08a1d26 commit 45097da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/io_uring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,8 +2493,9 @@ static void io_req_map_rw(struct io_kiocb *req, ssize_t io_size,
24932493
req->io->rw.iov = iovec;
24942494
if (!req->io->rw.iov) {
24952495
req->io->rw.iov = req->io->rw.fast_iov;
2496-
memcpy(req->io->rw.iov, fast_iov,
2497-
sizeof(struct iovec) * iter->nr_segs);
2496+
if (req->io->rw.iov != fast_iov)
2497+
memcpy(req->io->rw.iov, fast_iov,
2498+
sizeof(struct iovec) * iter->nr_segs);
24982499
} else {
24992500
req->flags |= REQ_F_NEED_CLEANUP;
25002501
}

0 commit comments

Comments
 (0)