Skip to content

Commit d4c81f3

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't arm a timeout through work.func
Remove io_link_work_cb() -- the last custom work.func. Not the prettiest thing, but works. Instead of queueing a linked timeout in io_link_work_cb() mark a request with REQ_F_QUEUE_TIMEOUT and do enqueueing based on the flag in io_wq_submit_work(). Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ac45abc commit d4c81f3

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

fs/io_uring.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ enum {
541541
REQ_F_POLLED_BIT,
542542
REQ_F_BUFFER_SELECTED_BIT,
543543
REQ_F_NO_FILE_TABLE_BIT,
544+
REQ_F_QUEUE_TIMEOUT_BIT,
544545

545546
/* not a real bit, just to check we're not overflowing the space */
546547
__REQ_F_LAST_BIT,
@@ -596,6 +597,8 @@ enum {
596597
REQ_F_BUFFER_SELECTED = BIT(REQ_F_BUFFER_SELECTED_BIT),
597598
/* doesn't need file table for this request */
598599
REQ_F_NO_FILE_TABLE = BIT(REQ_F_NO_FILE_TABLE_BIT),
600+
/* needs to queue linked timeout */
601+
REQ_F_QUEUE_TIMEOUT = BIT(REQ_F_QUEUE_TIMEOUT_BIT),
599602
};
600603

601604
struct async_poll {
@@ -1580,16 +1583,6 @@ static void io_free_req(struct io_kiocb *req)
15801583
io_queue_async_work(nxt);
15811584
}
15821585

1583-
static void io_link_work_cb(struct io_wq_work **workptr)
1584-
{
1585-
struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work);
1586-
struct io_kiocb *link;
1587-
1588-
link = list_first_entry(&req->link_list, struct io_kiocb, link_list);
1589-
io_queue_linked_timeout(link);
1590-
io_wq_submit_work(workptr);
1591-
}
1592-
15931586
static void io_wq_assign_next(struct io_wq_work **workptr, struct io_kiocb *nxt)
15941587
{
15951588
struct io_kiocb *link;
@@ -1601,7 +1594,7 @@ static void io_wq_assign_next(struct io_wq_work **workptr, struct io_kiocb *nxt)
16011594
*workptr = &nxt->work;
16021595
link = io_prep_linked_timeout(nxt);
16031596
if (link)
1604-
nxt->work.func = io_link_work_cb;
1597+
nxt->flags |= REQ_F_QUEUE_TIMEOUT;
16051598
}
16061599

16071600
/*
@@ -5291,12 +5284,26 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
52915284
return 0;
52925285
}
52935286

5287+
static void io_arm_async_linked_timeout(struct io_kiocb *req)
5288+
{
5289+
struct io_kiocb *link;
5290+
5291+
/* link head's timeout is queued in io_queue_async_work() */
5292+
if (!(req->flags & REQ_F_QUEUE_TIMEOUT))
5293+
return;
5294+
5295+
link = list_first_entry(&req->link_list, struct io_kiocb, link_list);
5296+
io_queue_linked_timeout(link);
5297+
}
5298+
52945299
static void io_wq_submit_work(struct io_wq_work **workptr)
52955300
{
52965301
struct io_wq_work *work = *workptr;
52975302
struct io_kiocb *req = container_of(work, struct io_kiocb, work);
52985303
int ret = 0;
52995304

5305+
io_arm_async_linked_timeout(req);
5306+
53005307
/* if NO_CANCEL is set, we must still run the work */
53015308
if ((work->flags & (IO_WQ_WORK_CANCEL|IO_WQ_WORK_NO_CANCEL)) ==
53025309
IO_WQ_WORK_CANCEL) {

0 commit comments

Comments
 (0)