Skip to content

Commit a76c0b3

Browse files
committed
io_uring: commit non-pollable provided mapped buffers upfront
For recv/recvmsg, IO either completes immediately or gets queued for a retry. This isn't the case for read/readv, if eg a normal file or a block device is used. Here, an operation can get queued with the block layer. If this happens, ring mapped buffers must get committed immediately to avoid that the next read can consume the same buffer. Check if we're dealing with pollable file, when getting a new ring mapped provided buffer. If it's not, commit it immediately rather than wait post issue. If we don't wait, we can race with completions coming in, or just plain buffer reuse by committing after a retry where others could have grabbed the same buffer. Fixes: c7fb194 ("io_uring: add support for ring mapped supplied buffers") Reviewed-by: Hao Xu <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c559597 commit a76c0b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3836,7 +3836,7 @@ static void __user *io_ring_buffer_select(struct io_kiocb *req, size_t *len,
38363836
req->buf_list = bl;
38373837
req->buf_index = buf->bid;
38383838

3839-
if (issue_flags & IO_URING_F_UNLOCKED) {
3839+
if (issue_flags & IO_URING_F_UNLOCKED || !file_can_poll(req->file)) {
38403840
/*
38413841
* If we came in unlocked, we have no choice but to consume the
38423842
* buffer here. This does mean it'll be pinned until the IO

0 commit comments

Comments
 (0)