Skip to content

Commit

Permalink
io_uring: abstract out a io_poll_find_helper()
Browse files Browse the repository at this point in the history
We'll need this helper for another purpose, for now just abstract it
out and have io_poll_cancel() use it for lookups.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed Apr 11, 2021
1 parent 5082620 commit b2cb805
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -5286,7 +5286,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
return posted != 0;
}

static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr)
{
struct hlist_head *list;
struct io_kiocb *req;
Expand All @@ -5295,12 +5295,23 @@ static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
hlist_for_each_entry(req, list, hash_node) {
if (sqe_addr != req->user_data)
continue;
if (io_poll_remove_one(req))
return 0;
return -EALREADY;
return req;
}

return -ENOENT;
return NULL;
}

static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
{
struct io_kiocb *req;

req = io_poll_find(ctx, sqe_addr);
if (!req)
return -ENOENT;
if (io_poll_remove_one(req))
return 0;

return -EALREADY;
}

static int io_poll_remove_prep(struct io_kiocb *req,
Expand Down

0 comments on commit b2cb805

Please sign in to comment.