Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/cancel: add generic remove_all helper

Any opcode that is cancelable ends up defining its own remove all
helper, which iterates the pending list and cancels matches. Add a
generic helper for it, which can be used by them.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+25
+21
io_uring/cancel.c
··· 341 341 fput(file); 342 342 return ret; 343 343 } 344 + 345 + bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx, 346 + struct hlist_head *list, bool cancel_all, 347 + bool (*cancel)(struct io_kiocb *)) 348 + { 349 + struct hlist_node *tmp; 350 + struct io_kiocb *req; 351 + bool found = false; 352 + 353 + lockdep_assert_held(&ctx->uring_lock); 354 + 355 + hlist_for_each_entry_safe(req, tmp, list, hash_node) { 356 + if (!io_match_task_safe(req, tctx, cancel_all)) 357 + continue; 358 + hlist_del_init(&req->hash_node); 359 + if (cancel(req)) 360 + found = true; 361 + } 362 + 363 + return found; 364 + }
+4
io_uring/cancel.h
··· 24 24 int io_sync_cancel(struct io_ring_ctx *ctx, void __user *arg); 25 25 bool io_cancel_req_match(struct io_kiocb *req, struct io_cancel_data *cd); 26 26 27 + bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx, 28 + struct hlist_head *list, bool cancel_all, 29 + bool (*cancel)(struct io_kiocb *)); 30 + 27 31 static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence) 28 32 { 29 33 if (req->cancel_seq_set && sequence == req->work.cancel_seq)