]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: commit non-pollable provided mapped buffers upfront
authorJens Axboe <axboe@kernel.dk>
Thu, 16 Jun 2022 01:51:11 +0000 (19:51 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 16 Jun 2022 13:14:44 +0000 (07:14 -0600)
commiteb346be06a667f1eb72f0f39e328aaa37b346b7f
treedfa5c6e86f7a6054822d6ffb84c118d8211a5ef6
parent43613aea7281e48bc4a21f877575056faf12f294
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: e790404d1245 ("io_uring: add support for ring mapped supplied buffers")
Reviewed-by: Hao Xu <howeyxu@tencent.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c