summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2025-02-05 13:15:57 -0700
committerJens Axboe <axboe@kernel.dk>2025-02-17 05:34:45 -0700
commit2eaa2fac4704d59f2fd07e496114c39303e54a18 (patch)
tree5752b188699f21cf84f65fb03e718ba349e27d4d
parent8fa374f90b721ae5f56605ff67fc94a8b583e10c (diff)
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 <axboe@kernel.dk>
-rw-r--r--io_uring/futex.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/io_uring/futex.c b/io_uring/futex.c
index 47b8c229a2e3..ede6279cadc6 100644
--- a/io_uring/futex.c
+++ b/io_uring/futex.c
@@ -116,29 +116,7 @@ static bool __io_futex_cancel(struct io_kiocb *req)
int io_futex_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd,
unsigned int issue_flags)
{
- struct hlist_node *tmp;
- struct io_kiocb *req;
- int nr = 0;
-
- if (cd->flags & (IORING_ASYNC_CANCEL_FD|IORING_ASYNC_CANCEL_FD_FIXED))
- return -ENOENT;
-
- io_ring_submit_lock(ctx, issue_flags);
- hlist_for_each_entry_safe(req, tmp, &ctx->futex_list, hash_node) {
- if (req->cqe.user_data != cd->data &&
- !(cd->flags & IORING_ASYNC_CANCEL_ANY))
- continue;
- if (__io_futex_cancel(req))
- nr++;
- if (!(cd->flags & IORING_ASYNC_CANCEL_ALL))
- break;
- }
- io_ring_submit_unlock(ctx, issue_flags);
-
- if (nr)
- return nr;
-
- return -ENOENT;
+ return io_cancel_remove(ctx, cd, issue_flags, &ctx->futex_list, __io_futex_cancel);
}
bool io_futex_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx,