Skip to content

Commit 26ec15e

Browse files
committed
io_uring/kbuf: don't truncate end buffer for multiple buffer peeks
If peeking a bunch of buffers, normally io_ring_buffers_peek() will truncate the end buffer. This isn't optimal as presumably more data will be arriving later, and hence it's better to stop with the last full buffer rather than truncate the end buffer. Cc: [email protected] Fixes: 35c8711 ("io_uring/kbuf: add helpers for getting/peeking multiple buffers") Reported-by: Christian Mazakas <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c538f40 commit 26ec15e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

io_uring/kbuf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,11 @@ static int io_ring_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg,
270270
/* truncate end piece, if needed, for non partial buffers */
271271
if (len > arg->max_len) {
272272
len = arg->max_len;
273-
if (!(bl->flags & IOBL_INC))
273+
if (!(bl->flags & IOBL_INC)) {
274+
if (iov != arg->iovs)
275+
break;
274276
buf->len = len;
277+
}
275278
}
276279

277280
iov->iov_base = u64_to_user_ptr(buf->addr);

0 commit comments

Comments
 (0)