Skip to content

Commit a6ba632

Browse files
committed
io_uring: retry poll if we got woken with non-matching mask
If we get woken and the poll doesn't match our mask, re-add the task to the poll waitqueue and try again instead of completing the request with a mask of 0. Reported-by: Dan Melnic <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 10bea96 commit a6ba632

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fs/io_uring.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4412,8 +4412,20 @@ static void io_poll_complete(struct io_kiocb *req, __poll_t mask, int error)
44124412
static void io_poll_task_handler(struct io_kiocb *req, struct io_kiocb **nxt)
44134413
{
44144414
struct io_ring_ctx *ctx = req->ctx;
4415+
struct io_poll_iocb *poll = &req->poll;
4416+
4417+
if (!req->result && !READ_ONCE(poll->canceled)) {
4418+
struct poll_table_struct pt = { ._key = poll->events };
4419+
4420+
req->result = vfs_poll(req->file, &pt) & poll->events;
4421+
}
44154422

44164423
spin_lock_irq(&ctx->completion_lock);
4424+
if (!req->result && !READ_ONCE(poll->canceled)) {
4425+
add_wait_queue(poll->head, &poll->wait);
4426+
spin_unlock_irq(&ctx->completion_lock);
4427+
return;
4428+
}
44174429
hash_del(&req->hash_node);
44184430
io_poll_complete(req, req->result, 0);
44194431
req->flags |= REQ_F_COMP_LOCKED;

0 commit comments

Comments
 (0)