Skip to content

Commit 704ea88

Browse files
committed
io_uring/poll: add requeue return code from poll multishot handling
Since our poll handling is edge triggered, multishot handlers retry internally until they know that no more data is available. In preparation for limiting these retries, add an internal return code, IOU_REQUEUE, which can be used to inform the poll backend about the handler wanting to retry, but that this should happen through a normal task_work requeue rather than keep hammering on the issue side for this one request. No functional changes in this patch, nobody is using this return code just yet. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 91e5d76 commit 704ea88

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

io_uring/io_uring.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515
#include <trace/events/io_uring.h>
1616
#endif
1717

18-
1918
enum {
2019
IOU_OK = 0,
2120
IOU_ISSUE_SKIP_COMPLETE = -EIOCBQUEUED,
2221

22+
/*
23+
* Requeue the task_work to restart operations on this request. The
24+
* actual value isn't important, should just be not an otherwise
25+
* valid error code, yet less than -MAX_ERRNO and valid internally.
26+
*/
27+
IOU_REQUEUE = -3072,
28+
2329
/*
2430
* Intended only when both IO_URING_F_MULTISHOT is passed
2531
* to indicate to the poll runner that multishot should be

io_uring/poll.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ enum {
226226
IOU_POLL_NO_ACTION = 1,
227227
IOU_POLL_REMOVE_POLL_USE_RES = 2,
228228
IOU_POLL_REISSUE = 3,
229+
IOU_POLL_REQUEUE = 4,
229230
};
230231

231232
static void __io_poll_execute(struct io_kiocb *req, int mask)
@@ -329,6 +330,8 @@ static int io_poll_check_events(struct io_kiocb *req, struct io_tw_state *ts)
329330
int ret = io_poll_issue(req, ts);
330331
if (ret == IOU_STOP_MULTISHOT)
331332
return IOU_POLL_REMOVE_POLL_USE_RES;
333+
else if (ret == IOU_REQUEUE)
334+
return IOU_POLL_REQUEUE;
332335
if (ret < 0)
333336
return ret;
334337
}
@@ -351,8 +354,12 @@ void io_poll_task_func(struct io_kiocb *req, struct io_tw_state *ts)
351354
int ret;
352355

353356
ret = io_poll_check_events(req, ts);
354-
if (ret == IOU_POLL_NO_ACTION)
357+
if (ret == IOU_POLL_NO_ACTION) {
355358
return;
359+
} else if (ret == IOU_POLL_REQUEUE) {
360+
__io_poll_execute(req, 0);
361+
return;
362+
}
356363
io_poll_remove_entries(req);
357364
io_poll_tw_hash_eject(req, ts);
358365

0 commit comments

Comments
 (0)