Skip to content

Commit

Permalink
io_uring: add a helper for poll clean
Browse files Browse the repository at this point in the history
Add a helper for poll clean, it will be used in the multishot accept in
the later patches.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
  • Loading branch information
Hao Xu authored and intel-lab-lkp committed May 6, 2022
1 parent 6001c3e commit acb232e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions fs/io_uring.c
Expand Up @@ -5711,6 +5711,23 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return 0;
}

static inline void __io_poll_clean(struct io_kiocb *req)
{
struct io_ring_ctx *ctx = req->ctx;

io_poll_remove_entries(req);
spin_lock(&ctx->completion_lock);
hash_del(&req->hash_node);
spin_unlock(&ctx->completion_lock);
}

#define REQ_F_APOLL_MULTI_POLLED (REQ_F_APOLL_MULTISHOT | REQ_F_POLLED)
static inline void io_poll_clean(struct io_kiocb *req)
{
if ((req->flags & REQ_F_APOLL_MULTI_POLLED) == REQ_F_APOLL_MULTI_POLLED)
__io_poll_clean(req);
}

static int io_accept(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_accept *accept = &req->accept;
Expand Down Expand Up @@ -6041,17 +6058,13 @@ static void io_poll_task_func(struct io_kiocb *req, bool *locked)

static void io_apoll_task_func(struct io_kiocb *req, bool *locked)
{
struct io_ring_ctx *ctx = req->ctx;
int ret;

ret = io_poll_check_events(req, locked);
if (ret > 0)
return;

io_poll_remove_entries(req);
spin_lock(&ctx->completion_lock);
hash_del(&req->hash_node);
spin_unlock(&ctx->completion_lock);
__io_poll_clean(req);

if (!ret)
io_req_task_submit(req, locked);
Expand Down

0 comments on commit acb232e

Please sign in to comment.