diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-04-20 19:27:41 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-04-24 18:18:18 -0600 |
commit | 10c873334febaeea9aa0c25c10b5ac0951b77a5f (patch) | |
tree | 1d0770df86158bf28ca69ff21fc08b813f4f2ab8 | |
parent | 4c3c09439c08b03d9503df0ca4c7619c5842892e (diff) | |
download | linux-10c873334febaeea9aa0c25c10b5ac0951b77a5f.tar.gz linux-10c873334febaeea9aa0c25c10b5ac0951b77a5f.tar.bz2 linux-10c873334febaeea9aa0c25c10b5ac0951b77a5f.zip |
io_uring: allow re-poll if we made progress
We currently check REQ_F_POLLED before arming async poll for a
notification to retry. If it's set, then we don't allow poll and will
punt to io-wq instead. This is done to prevent a situation where a buggy
driver will repeatedly return that there's space/data available yet we
get -EAGAIN.
However, if we already transferred data, then it should be safe to rely
on poll again. Gate the check on whether or not REQ_F_PARTIAL_IO is
also set.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index e18d8891b98b..97ed7f419dae 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6266,7 +6266,9 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags) if (!def->pollin && !def->pollout) return IO_APOLL_ABORTED; - if (!file_can_poll(req->file) || (req->flags & REQ_F_POLLED)) + if (!file_can_poll(req->file)) + return IO_APOLL_ABORTED; + if ((req->flags & (REQ_F_POLLED|REQ_F_PARTIAL_IO)) == REQ_F_POLLED) return IO_APOLL_ABORTED; if (def->pollin) { @@ -6281,8 +6283,10 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags) } if (def->poll_exclusive) mask |= EPOLLEXCLUSIVE; - if (!(issue_flags & IO_URING_F_UNLOCKED) && - !list_empty(&ctx->apoll_cache)) { + if (req->flags & REQ_F_POLLED) { + apoll = req->apoll; + } else if (!(issue_flags & IO_URING_F_UNLOCKED) && + !list_empty(&ctx->apoll_cache)) { apoll = list_first_entry(&ctx->apoll_cache, struct async_poll, poll.wait.entry); list_del_init(&apoll->poll.wait.entry); |