aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe2020-03-11 12:27:04 -0600
committerJens Axboe2020-03-11 12:29:15 -0600
commit3f9d64415fdaa73017fcb168930006648617b488 (patch)
tree7be5027c3229747e267e930ed3efc9a962e3e803
parentbbbdeb4720a0759ec90e3bcb20ad28d19e531346 (diff)
io_uring: fix truncated async read/readv and write/writev retry
Ensure we keep the truncated value, if we did truncate it. If not, we might read/write more than the registered buffer size. Also for retry, ensure that we return the truncated mapped value for the vectorized versions of the read/write commands. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/io_uring.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9f1a462eb780..55afae6f0cf4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2360,6 +2360,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
*iovec = NULL;
return PTR_ERR(buf);
}
+ req->rw.len = sqe_len;
}
ret = import_single_range(rw, buf, sqe_len, *iovec, iter);
@@ -2379,8 +2380,10 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
if (req->flags & REQ_F_BUFFER_SELECT) {
ret = io_iov_buffer_select(req, *iovec, needs_lock);
- if (!ret)
- iov_iter_init(iter, rw, *iovec, 1, (*iovec)->iov_len);
+ if (!ret) {
+ ret = (*iovec)->iov_len;
+ iov_iter_init(iter, rw, *iovec, 1, ret);
+ }
*iovec = NULL;
return ret;
}