diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-01-27 13:44:58 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-01-28 20:37:11 -0700 |
commit | c79f52f0656eeb3e4a12f7f358f760077ae111b6 (patch) | |
tree | 8ae97928cb77a34d5f3913fe4ac93c4ce03b0537 /io_uring/poll.c | |
parent | 16bae3e1377846734ec6b87eee459c0f3551692c (diff) | |
download | lwn-c79f52f0656eeb3e4a12f7f358f760077ae111b6.tar.gz lwn-c79f52f0656eeb3e4a12f7f358f760077ae111b6.zip |
io_uring/rw: ensure poll based multishot read retries appropriately
io_read_mshot() always relies on poll triggering retries, and this works
fine as long as we do a retry per size of the buffer being read. The
buffer size is given by the size of the buffer(s) in the given buffer
group ID.
But if we're reading less than what is available, then we don't always
get to read everything that is available. For example, if the buffers
available are 32 bytes and we have 64 bytes to read, then we'll
correctly read the first 32 bytes and then wait for another poll trigger
before we attempt the next read. This next poll trigger may never
happen, in which case we just sit forever and never make progress, or it
may trigger at some point in the future, and now we're just delivering
the available data much later than we should have.
io_read_mshot() could do retries itself, but that is wasteful as we'll
be going through all of __io_read() again, and most likely in vain.
Rather than do that, bump our poll reference count and have
io_poll_check_events() do one more loop and check with vfs_poll() if we
have more data to read. If we do, io_read_mshot() will get invoked again
directly and we'll read the next chunk.
io_poll_multishot_retry() must only get called from inside
io_poll_issue(), which is our multishot retry handler, as we know we
already "own" the request at this point.
Cc: stable@vger.kernel.org
Link: https://github.com/axboe/liburing/issues/1041
Fixes: fc68fcda0491 ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/poll.c')
0 files changed, 0 insertions, 0 deletions