static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
			void *key)
{
	struct io_poll_iocb *poll = wait->private;
	struct io_kiocb *req = container_of(poll, struct io_kiocb, poll);
	struct io_ring_ctx *ctx = req->ctx;
	__poll_t mask = key_to_poll(key);

	/* for instances that support it check for an event match first: */
	if (mask && !(mask & poll->events))
		return 0;

	list_del_init(&poll->wait.entry);

	/*
	 * Run completion inline if we can. We're using trylock here because
	 * we are violating the completion_lock -> poll wq lock ordering.
	 * If we have a link timeout we're going to need the completion_lock
	 * for finalizing the request, mark us as having grabbed that already.
	 */
	if (mask) {
		unsigned long flags;

		if (llist_empty(&ctx->poll_llist) &&
		    spin_trylock_irqsave(&ctx->completion_lock, flags)) {
			bool trigger_ev;

			hash_del(&req->hash_node);
			io_poll_complete(req, mask, 0);

			trigger_ev = io_should_trigger_evfd(ctx);
			if (trigger_ev && eventfd_signal_count()) {
				trigger_ev = false;
				req->work.func = io_poll_trigger_evfd;
			} else {
				req->flags |= REQ_F_COMP_LOCKED;
				io_put_req(req);
				req = NULL;
			}
			spin_unlock_irqrestore(&ctx->completion_lock, flags);
			__io_cqring_ev_posted(ctx, trigger_ev);
		} else {
			req->result = mask;
			req->llist_node.next = NULL;
			/* if the list wasn't empty, we're done */
			if (!llist_add(&req->llist_node, &ctx->poll_llist))
				req = NULL;
			else
				req->work.func = io_poll_flush;
		}
	}
	if (req)
		io_queue_async_work(req);

	return 1;
}
static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
			void *key)
{
	struct io_poll_iocb *poll = wait->private;
	struct io_kiocb *req = container_of(poll, struct io_kiocb, poll);
	struct io_ring_ctx *ctx = req->ctx;
	__poll_t mask = key_to_poll(key);

	 
	if (mask && !(mask & poll->events))
		return 0;

	list_del_init(&poll->wait.entry);

	 
	if (mask) {
		unsigned long flags;

		if (llist_empty(&ctx->poll_llist) &&
		    spin_trylock_irqsave(&ctx->completion_lock, flags)) {
			bool trigger_ev;

			hash_del(&req->hash_node);
			io_poll_complete(req, mask, 0);

			trigger_ev = io_should_trigger_evfd(ctx);
			if (trigger_ev && eventfd_signal_count()) {
				trigger_ev = false;
				req->work.func = io_poll_trigger_evfd;
			} else {
				req->flags |= REQ_F_COMP_LOCKED;
				io_put_req(req);
				req = NULL;
			}
			spin_unlock_irqrestore(&ctx->completion_lock, flags);
			__io_cqring_ev_posted(ctx, trigger_ev);
		} else {
			req->result = mask;
			req->llist_node.next = NULL;
			 
			if (!llist_add(&req->llist_node, &ctx->poll_llist))
				req = NULL;
			else
				req->work.func = io_poll_flush;
		}
	}
	if (req)
		io_queue_async_work(req);

	return 1;
}