Skip to content

Commit b2cb805

Browse files
committed
io_uring: abstract out a io_poll_find_helper()
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 <[email protected]>
1 parent 5082620 commit b2cb805

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

fs/io_uring.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5286,7 +5286,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
52865286
return posted != 0;
52875287
}
52885288

5289-
static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
5289+
static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr)
52905290
{
52915291
struct hlist_head *list;
52925292
struct io_kiocb *req;
@@ -5295,12 +5295,23 @@ static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
52955295
hlist_for_each_entry(req, list, hash_node) {
52965296
if (sqe_addr != req->user_data)
52975297
continue;
5298-
if (io_poll_remove_one(req))
5299-
return 0;
5300-
return -EALREADY;
5298+
return req;
53015299
}
53025300

5303-
return -ENOENT;
5301+
return NULL;
5302+
}
5303+
5304+
static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
5305+
{
5306+
struct io_kiocb *req;
5307+
5308+
req = io_poll_find(ctx, sqe_addr);
5309+
if (!req)
5310+
return -ENOENT;
5311+
if (io_poll_remove_one(req))
5312+
return 0;
5313+
5314+
return -EALREADY;
53045315
}
53055316

53065317
static int io_poll_remove_prep(struct io_kiocb *req,

0 commit comments

Comments
 (0)