io_free_batch_list() iterates all requests in the passed in list, so we don't really need to know the tail but can keep iterating until meet NULL. Just pass the first node into it and it will be enough. Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- fs/io_uring.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 8d2aa0951579..f8640959554b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2270,14 +2270,12 @@ static void io_free_req_work(struct io_kiocb *req, bool *locked) } static void io_free_batch_list(struct io_ring_ctx *ctx, - struct io_wq_work_list *list) + struct io_wq_work_node *node) __must_hold(&ctx->uring_lock) { - struct io_wq_work_node *node; struct task_struct *task = NULL; int task_refs = 0, ctx_refs = 0; - node = list->first; do { struct io_kiocb *req = container_of(node, struct io_kiocb, comp_list); @@ -2324,7 +2322,7 @@ static void __io_submit_flush_completions(struct io_ring_ctx *ctx) spin_unlock(&ctx->completion_lock); io_cqring_ev_posted(ctx); - io_free_batch_list(ctx, &state->compl_reqs); + io_free_batch_list(ctx, state->compl_reqs.first); INIT_WQ_LIST(&state->compl_reqs); } @@ -2407,7 +2405,6 @@ static inline bool io_run_task_work(void) static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin) { struct io_wq_work_node *pos, *start, *prev; - struct io_wq_work_list list; int nr_events = 0; bool spin; @@ -2461,10 +2458,9 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin) io_commit_cqring(ctx); io_cqring_ev_posted_iopoll(ctx); - list.first = start ? start->next : ctx->iopoll_list.first; - list.last = prev; + pos = start ? start->next : ctx->iopoll_list.first; wq_list_cut(&ctx->iopoll_list, prev, start); - io_free_batch_list(ctx, &list); + io_free_batch_list(ctx, pos); return nr_events; } -- 2.33.0