Skip to content

Commit edd43f4

Browse files
committed
io_uring: fix 'sync' handling of io_fallback_tw()
A previous commit added a 'sync' parameter to io_fallback_tw(), which if true, means the caller wants to wait on the fallback thread handling it. But the logic is somewhat messed up, ensure that ctxs are swapped and flushed appropriately. Cc: stable@vger.kernel.org Fixes: dfbe556 ("io_uring: flush offloaded and delayed task_work on exit") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5e16f1a commit edd43f4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

io_uring/io_uring.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,21 +1083,22 @@ static __cold void __io_fallback_tw(struct llist_node *node, bool sync)
10831083
while (node) {
10841084
req = container_of(node, struct io_kiocb, io_task_work.node);
10851085
node = node->next;
1086-
if (sync && last_ctx != req->ctx) {
1086+
if (last_ctx != req->ctx) {
10871087
if (last_ctx) {
1088-
flush_delayed_work(&last_ctx->fallback_work);
1088+
if (sync)
1089+
flush_delayed_work(&last_ctx->fallback_work);
10891090
percpu_ref_put(&last_ctx->refs);
10901091
}
10911092
last_ctx = req->ctx;
10921093
percpu_ref_get(&last_ctx->refs);
10931094
}
1094-
if (llist_add(&req->io_task_work.node,
1095-
&req->ctx->fallback_llist))
1096-
schedule_delayed_work(&req->ctx->fallback_work, 1);
1095+
if (llist_add(&req->io_task_work.node, &last_ctx->fallback_llist))
1096+
schedule_delayed_work(&last_ctx->fallback_work, 1);
10971097
}
10981098

10991099
if (last_ctx) {
1100-
flush_delayed_work(&last_ctx->fallback_work);
1100+
if (sync)
1101+
flush_delayed_work(&last_ctx->fallback_work);
11011102
percpu_ref_put(&last_ctx->refs);
11021103
}
11031104
}

0 commit comments

Comments
 (0)