io_uring/rw: don't allow multishot reads without NOWAIT support

JIRA: https://issues.redhat.com/browse/RHEL-27755

commit 2a975d426c82ff05ec1f0b773798d909fe4a3105
Author: Jens Axboe <axboe@kernel.dk>
Date:   Mon Apr 1 11:27:33 2024 -0600

    io_uring/rw: don't allow multishot reads without NOWAIT support
    
    Supporting multishot reads requires support for NOWAIT, as the
    alternative would be always having io-wq execute the work item whenever
    the poll readiness triggered. Any fast file type will have NOWAIT
    support (eg it understands both O_NONBLOCK and IOCB_NOWAIT). If the
    given file type does not, then simply resort to single shot execution.
    
    Cc: stable@vger.kernel.org
    Fixes: fc68fcda04910 ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT")
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
This commit is contained in:
Jeff Moyer 2024-04-01 11:27:33 -06:00
parent 2ee1019058
commit 4ea4bc14fb
1 changed files with 8 additions and 1 deletions

View File

@ -937,6 +937,13 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
ret = __io_read(req, issue_flags); ret = __io_read(req, issue_flags);
/*
* If the file doesn't support proper NOWAIT, then disable multishot
* and stay in single shot mode.
*/
if (!io_file_supports_nowait(req))
req->flags &= ~REQ_F_APOLL_MULTISHOT;
/* /*
* If we get -EAGAIN, recycle our buffer and just let normal poll * If we get -EAGAIN, recycle our buffer and just let normal poll
* handling arm it. * handling arm it.
@ -956,7 +963,7 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
/* /*
* Any successful return value will keep the multishot read armed. * Any successful return value will keep the multishot read armed.
*/ */
if (ret > 0) { if (ret > 0 && req->flags & REQ_F_APOLL_MULTISHOT) {
/* /*
* Put our buffer and post a CQE. If we fail to post a CQE, then * Put our buffer and post a CQE. If we fail to post a CQE, then
* jump to the termination path. This request is then done. * jump to the termination path. This request is then done.