Skip to content

Commit

Permalink
io_uring: fix explicit async read/write mapping for large segments
Browse files Browse the repository at this point in the history
ANBZ: torvalds#190

commit c183edf upstream.

If we exceed UIO_FASTIOV, we don't handle the transition correctly
between an allocated vec for requests that are queued with IOSQE_ASYNC.
Store the iovec appropriately and re-set it in the iter iov in case
it changed.

Fixes: ff6165b ("io_uring: retain iov_iter state over io_read/io_write calls")
Reported-by: Nick Hill <nick@nickhill.org>
Tested-by: Norman Maurer <norman.maurer@googlemail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Reviewed-by: Hao Xu <haoxu@linux.alibaba.com>
Tested-by: Hao Xu <haoxu@linux.alibaba.com>
  • Loading branch information
axboe authored and josephhz committed Dec 31, 2021
1 parent ae1d80b commit a27d73e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2901,17 +2901,18 @@ static inline int io_rw_prep_async(struct io_kiocb *req, int rw,
bool force_nonblock)
{
struct io_async_rw *iorw = &req->io->rw;
struct iovec *iov;
ssize_t ret;

iorw->iter.iov = iorw->fast_iov;
iorw->iter.iov = iov = iorw->fast_iov;
/* reset ->io around the iovec import, we don't want to use it */
req->io = NULL;
ret = io_import_iovec(rw, req, (struct iovec **) &iorw->iter.iov,
&iorw->iter, !force_nonblock);
ret = io_import_iovec(rw, req, &iov, &iorw->iter, !force_nonblock);
req->io = container_of(iorw, struct io_async_ctx, rw);
if (unlikely(ret < 0))
return ret;

iorw->iter.iov = iov;
io_req_map_rw(req, iorw->iter.iov, iorw->fast_iov, &iorw->iter);
return 0;
}
Expand Down

0 comments on commit a27d73e

Please sign in to comment.