Skip to content

Commit 932de5e

Browse files
committed
io_uring/waitid: use generic io_cancel_remove() helper
Don't implement our own loop rolling and checking, just use the generic helper to find and cancel requests. Signed-off-by: Jens Axboe <[email protected]>
1 parent 2eaa2fa commit 932de5e

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

io_uring/waitid.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -158,29 +158,7 @@ static bool __io_waitid_cancel(struct io_kiocb *req)
158158
int io_waitid_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
159159
unsigned int issue_flags)
160160
{
161-
struct hlist_node *tmp;
162-
struct io_kiocb *req;
163-
int nr = 0;
164-
165-
if (cd->flags & (IORING_ASYNC_CANCEL_FD|IORING_ASYNC_CANCEL_FD_FIXED))
166-
return -ENOENT;
167-
168-
io_ring_submit_lock(ctx, issue_flags);
169-
hlist_for_each_entry_safe(req, tmp, &ctx->waitid_list, hash_node) {
170-
if (req->cqe.user_data != cd->data &&
171-
!(cd->flags & IORING_ASYNC_CANCEL_ANY))
172-
continue;
173-
if (__io_waitid_cancel(req))
174-
nr++;
175-
if (!(cd->flags & IORING_ASYNC_CANCEL_ALL))
176-
break;
177-
}
178-
io_ring_submit_unlock(ctx, issue_flags);
179-
180-
if (nr)
181-
return nr;
182-
183-
return -ENOENT;
161+
return io_cancel_remove(ctx, cd, issue_flags, &ctx->waitid_list, __io_waitid_cancel);
184162
}
185163

186164
bool io_waitid_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,

0 commit comments

Comments
 (0)