}
if (*locked)
- io_req_add_compl_list(req);
+ io_req_complete_defer(req);
else
io_req_complete_post(req);
}
if (ret == IOU_OK) {
if (issue_flags & IO_URING_F_COMPLETE_DEFER)
- io_req_add_compl_list(req);
+ io_req_complete_defer(req);
else
io_req_complete_post(req);
} else if (ret != IOU_ISSUE_SKIP_COMPLETE)
}
}
-static inline void io_req_add_compl_list(struct io_kiocb *req)
+/*
+ * Don't complete immediately but use deferred completion infrastructure.
+ * Protected by ->uring_lock and can only be used either with
+ * IO_URING_F_COMPLETE_DEFER or inside a tw handler holding the mutex.
+ */
+static inline void io_req_complete_defer(struct io_kiocb *req)
+ __must_hold(&req->ctx->uring_lock)
{
struct io_submit_state *state = &req->ctx->submit_state;
+ lockdep_assert_held(&req->ctx->uring_lock);
+
wq_list_add_tail(&req->comp_list, &state->compl_reqs);
}