Skip to content

Commit 7d9944f

Browse files
committed
io_uring/waitid: convert to io_cancel_remove_all()
Use the generic helper for cancelations. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e855b91 commit 7d9944f

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

io_uring/waitid.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void io_waitid_complete(struct io_kiocb *req, int ret)
132132
io_req_set_res(req, ret, 0);
133133
}
134134

135-
static bool __io_waitid_cancel(struct io_ring_ctx *ctx, struct io_kiocb *req)
135+
static bool __io_waitid_cancel(struct io_kiocb *req)
136136
{
137137
struct io_waitid *iw = io_kiocb_to_cmd(req, struct io_waitid);
138138
struct io_waitid_async *iwa = req->async_data;
@@ -170,7 +170,7 @@ int io_waitid_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
170170
if (req->cqe.user_data != cd->data &&
171171
!(cd->flags & IORING_ASYNC_CANCEL_ANY))
172172
continue;
173-
if (__io_waitid_cancel(ctx, req))
173+
if (__io_waitid_cancel(req))
174174
nr++;
175175
if (!(cd->flags & IORING_ASYNC_CANCEL_ALL))
176176
break;
@@ -186,21 +186,7 @@ int io_waitid_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
186186
bool io_waitid_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,
187187
bool cancel_all)
188188
{
189-
struct hlist_node *tmp;
190-
struct io_kiocb *req;
191-
bool found = false;
192-
193-
lockdep_assert_held(&ctx->uring_lock);
194-
195-
hlist_for_each_entry_safe(req, tmp, &ctx->waitid_list, hash_node) {
196-
if (!io_match_task_safe(req, tctx, cancel_all))
197-
continue;
198-
hlist_del_init(&req->hash_node);
199-
__io_waitid_cancel(ctx, req);
200-
found = true;
201-
}
202-
203-
return found;
189+
return io_cancel_remove_all(ctx, tctx, &ctx->waitid_list, cancel_all, __io_waitid_cancel);
204190
}
205191

206192
static inline bool io_waitid_drop_issue_ref(struct io_kiocb *req)

0 commit comments

Comments
 (0)