Skip to content

Commit 2eaa2fa

Browse files
committed
io_uring/futex: 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 8fa374f commit 2eaa2fa

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

io_uring/futex.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,7 @@ static bool __io_futex_cancel(struct io_kiocb *req)
116116
int io_futex_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
117117
unsigned int issue_flags)
118118
{
119-
struct hlist_node *tmp;
120-
struct io_kiocb *req;
121-
int nr = 0;
122-
123-
if (cd->flags & (IORING_ASYNC_CANCEL_FD|IORING_ASYNC_CANCEL_FD_FIXED))
124-
return -ENOENT;
125-
126-
io_ring_submit_lock(ctx, issue_flags);
127-
hlist_for_each_entry_safe(req, tmp, &ctx->futex_list, hash_node) {
128-
if (req->cqe.user_data != cd->data &&
129-
!(cd->flags & IORING_ASYNC_CANCEL_ANY))
130-
continue;
131-
if (__io_futex_cancel(req))
132-
nr++;
133-
if (!(cd->flags & IORING_ASYNC_CANCEL_ALL))
134-
break;
135-
}
136-
io_ring_submit_unlock(ctx, issue_flags);
137-
138-
if (nr)
139-
return nr;
140-
141-
return -ENOENT;
119+
return io_cancel_remove(ctx, cd, issue_flags, &ctx->futex_list, __io_futex_cancel);
142120
}
143121

144122
bool io_futex_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,

0 commit comments

Comments
 (0)