Skip to content

Commit cd664b0

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix hanging iopoll in case of -EAGAIN
io_do_iopoll() won't do anything with a request unless req->iopoll_completed is set. So io_complete_rw_iopoll() has to set it, otherwise io_do_iopoll() will poll a file again and again even though the request of interest was completed long time ago. Also, remove -EAGAIN check from io_issue_sqe() as it races with the changed lines. The request will take the long way and be resubmitted from io_iopoll*(). io_kiocb's result and iopoll_completed") Fixes: bbde017 ("io_uring: add memory barrier to synchronize Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b772f07 commit cd664b0

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

fs/io_uring.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,10 +1994,8 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)
19941994

19951995
WRITE_ONCE(req->result, res);
19961996
/* order with io_poll_complete() checking ->result */
1997-
if (res != -EAGAIN) {
1998-
smp_wmb();
1999-
WRITE_ONCE(req->iopoll_completed, 1);
2000-
}
1997+
smp_wmb();
1998+
WRITE_ONCE(req->iopoll_completed, 1);
20011999
}
20022000

20032001
/*
@@ -5353,9 +5351,6 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
53535351
if ((ctx->flags & IORING_SETUP_IOPOLL) && req->file) {
53545352
const bool in_async = io_wq_current_is_worker();
53555353

5356-
if (req->result == -EAGAIN)
5357-
return -EAGAIN;
5358-
53595354
/* workqueue context doesn't hold uring_lock, grab it now */
53605355
if (in_async)
53615356
mutex_lock(&ctx->uring_lock);

0 commit comments

Comments
 (0)