int ret = 0;
unsigned long check_cq;
+ if (!io_allowed_run_tw(ctx))
+ return -EEXIST;
+
check_cq = READ_ONCE(ctx->check_cq);
if (unlikely(check_cq)) {
if (check_cq & BIT(IO_CHECK_CQ_OVERFLOW_BIT))
ktime_t timeout = KTIME_MAX;
int ret;
+ if (!io_allowed_run_tw(ctx))
+ return -EEXIST;
+
do {
/* always run at least 1 task work to process local work */
ret = io_run_task_work_ctx(ctx);
return container_of(node, struct io_kiocb, comp_list);
}
+static inline bool io_allowed_run_tw(struct io_ring_ctx *ctx)
+{
+ if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))
+ return true;
+ if (unlikely(ctx->submitter_task != current)) {
+ /* maybe this is before any submissions */
+ return !ctx->submitter_task;
+ }
+ return true;
+}
+
#endif