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 cancel helper

Any opcode that is cancelable ends up defining its own cancel helper
for finding and canceling a specific request. Add a generic helper that
can be used for this purpose.

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

+25
+21
io_uring/cancel.c
··· 362 362 363 363 return found; 364 364 } 365 + 366 + int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd, 367 + unsigned int issue_flags, struct hlist_head *list, 368 + bool (*cancel)(struct io_kiocb *)) 369 + { 370 + struct hlist_node *tmp; 371 + struct io_kiocb *req; 372 + int nr = 0; 373 + 374 + io_ring_submit_lock(ctx, issue_flags); 375 + hlist_for_each_entry_safe(req, tmp, list, hash_node) { 376 + if (!io_cancel_req_match(req, cd)) 377 + continue; 378 + if (cancel(req)) 379 + nr++; 380 + if (!(cd->flags & IORING_ASYNC_CANCEL_ALL)) 381 + break; 382 + } 383 + io_ring_submit_unlock(ctx, issue_flags); 384 + return nr ?: -ENOENT; 385 + }
+4
io_uring/cancel.h
··· 28 28 struct hlist_head *list, bool cancel_all, 29 29 bool (*cancel)(struct io_kiocb *)); 30 30 31 + int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd, 32 + unsigned int issue_flags, struct hlist_head *list, 33 + bool (*cancel)(struct io_kiocb *)); 34 + 31 35 static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence) 32 36 { 33 37 if (req->cancel_seq_set && sequence == req->work.cancel_seq)