Skip to content

Commit 10c8733

Browse files
committed
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 <[email protected]>
1 parent 4c3c094 commit 10c8733

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/io_uring.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6266,7 +6266,9 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
62666266

62676267
if (!def->pollin && !def->pollout)
62686268
return IO_APOLL_ABORTED;
6269-
if (!file_can_poll(req->file) || (req->flags & REQ_F_POLLED))
6269+
if (!file_can_poll(req->file))
6270+
return IO_APOLL_ABORTED;
6271+
if ((req->flags & (REQ_F_POLLED|REQ_F_PARTIAL_IO)) == REQ_F_POLLED)
62706272
return IO_APOLL_ABORTED;
62716273

62726274
if (def->pollin) {
@@ -6281,8 +6283,10 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
62816283
}
62826284
if (def->poll_exclusive)
62836285
mask |= EPOLLEXCLUSIVE;
6284-
if (!(issue_flags & IO_URING_F_UNLOCKED) &&
6285-
!list_empty(&ctx->apoll_cache)) {
6286+
if (req->flags & REQ_F_POLLED) {
6287+
apoll = req->apoll;
6288+
} else if (!(issue_flags & IO_URING_F_UNLOCKED) &&
6289+
!list_empty(&ctx->apoll_cache)) {
62866290
apoll = list_first_entry(&ctx->apoll_cache, struct async_poll,
62876291
poll.wait.entry);
62886292
list_del_init(&apoll->poll.wait.entry);

0 commit comments

Comments
 (0)