Skip to content

RFC Add io_uring_register() based cancel

Jens Axboe io-uring 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3io_uring: have cancelation API accept io_uring_task directlyio_uring/cancel.c io_uring/cancel.h io_uring/timeout.c+11 -100 replies
2/3io_uring: add IORING_ASYNC_CANCEL_FD_FIXED cancel flaginclude/uapi/linux/io_uring.h io_uring/cancel.c+8 -30 replies
3/3io_uring: add sync cancelation API through io_uring_register()include/uapi/linux/io_uring.h io_uring/cancel.c io_uring/cancel.h +1 more+130 -02 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCHSET RFC for-next 0/3] Add io_uring_register() based cancel

Hi,

One of the tricky parts of cancelations is work that is handled by io-wq, and the regular cancelation API is naturally async and just returns -EALREADY for work in that state. This means that the work cancelation has been started, but we don't know if it's done yet.

With an async API for cancelation, we really can't do much better than that. This leaves the application canceling work to need to wait for a CQE from the original request.

Add a way to do sync cancel, even for io-wq. Since this isn't a natural fit for an SQE based cancel, add it via io_uring_register(), adding a IORING_REGISTER_SYNC_CANCEL operation. If we get -EALREADY, we wait for completions to come in. When they do, we re-check. Once we get -ENOENT for a lookup that previously gave us -EALREADY, we know the targeted requests have been stopped.

By utilizing the usual ctx->cq_wait to trigger a retry of the cancel operation, we avoid adding any kind of extra overhead to the normal completion path and tracking specific requests.

This gives applications an easy way to cancel any kind of request, and know that buffers associated with them will not be touched by the kernel. This effectively returns ownership of the data back to the application.

Signature · 1 line
Jens Axboe