Skip to content

Commit 360428f

Browse files
isilenceaxboe
authored andcommitted
io_uring: move timeouts flushing to a helper
Separate flushing offset timeouts io_commit_cqring() by moving it into a helper. Just a preparation, makes following patches clearer. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6f88cc1 commit 360428f

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

fs/io_uring.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -988,23 +988,6 @@ static inline bool req_need_defer(struct io_kiocb *req)
988988
return false;
989989
}
990990

991-
static struct io_kiocb *io_get_timeout_req(struct io_ring_ctx *ctx)
992-
{
993-
struct io_kiocb *req;
994-
995-
req = list_first_entry_or_null(&ctx->timeout_list, struct io_kiocb, list);
996-
if (req) {
997-
if (req->flags & REQ_F_TIMEOUT_NOSEQ)
998-
return NULL;
999-
if (!__req_need_defer(req)) {
1000-
list_del_init(&req->list);
1001-
return req;
1002-
}
1003-
}
1004-
1005-
return NULL;
1006-
}
1007-
1008991
static void __io_commit_cqring(struct io_ring_ctx *ctx)
1009992
{
1010993
struct io_rings *rings = ctx->rings;
@@ -1133,13 +1116,24 @@ static void __io_queue_deferred(struct io_ring_ctx *ctx)
11331116
} while (!list_empty(&ctx->defer_list));
11341117
}
11351118

1136-
static void io_commit_cqring(struct io_ring_ctx *ctx)
1119+
static void io_flush_timeouts(struct io_ring_ctx *ctx)
11371120
{
1138-
struct io_kiocb *req;
1121+
while (!list_empty(&ctx->timeout_list)) {
1122+
struct io_kiocb *req = list_first_entry(&ctx->timeout_list,
1123+
struct io_kiocb, list);
11391124

1140-
while ((req = io_get_timeout_req(ctx)) != NULL)
1125+
if (req->flags & REQ_F_TIMEOUT_NOSEQ)
1126+
break;
1127+
if (__req_need_defer(req))
1128+
break;
1129+
list_del_init(&req->list);
11411130
io_kill_timeout(req);
1131+
}
1132+
}
11421133

1134+
static void io_commit_cqring(struct io_ring_ctx *ctx)
1135+
{
1136+
io_flush_timeouts(ctx);
11431137
__io_commit_cqring(ctx);
11441138

11451139
if (unlikely(!list_empty(&ctx->defer_list)))

0 commit comments

Comments
 (0)