}
 }
 
-static bool io_poll_complete(struct io_kiocb *req, __poll_t mask)
+static bool __io_poll_complete(struct io_kiocb *req, __poll_t mask)
        __must_hold(&req->ctx->completion_lock)
 {
        struct io_ring_ctx *ctx = req->ctx;
        if (flags & IORING_CQE_F_MORE)
                ctx->cq_extra++;
 
-       io_commit_cqring(ctx);
        return !(flags & IORING_CQE_F_MORE);
 }
 
+static inline bool io_poll_complete(struct io_kiocb *req, __poll_t mask)
+       __must_hold(&req->ctx->completion_lock)
+{
+       bool done;
+
+       done = __io_poll_complete(req, mask);
+       io_commit_cqring(req->ctx);
+       return done;
+}
+
 static void io_poll_task_func(struct io_kiocb *req, bool *locked)
 {
        struct io_ring_ctx *ctx = req->ctx;
        } else {
                bool done;
 
-               done = io_poll_complete(req, req->result);
+               done = __io_poll_complete(req, req->result);
                if (done) {
                        io_poll_remove_double(req);
                        hash_del(&req->hash_node);
                        req->result = 0;
                        add_wait_queue(req->poll.head, &req->poll.wait);
                }
+               io_commit_cqring(ctx);
                spin_unlock(&ctx->completion_lock);
                io_cqring_ev_posted(ctx);