Replies: 6 comments 1 reply
-
I think adding an op match for cancelation makes the most sense, both for your case and in general. Let me take a look at it... |
Beta Was this translation helpful? Give feedback.
-
Here's a branch on top of what's queued for 6.5, the top two patches add op based canceling: https://git.kernel.dk/cgit/linux/log/?h=io_uring-cancel-op Ran a brief test and it seems to work for me. You'd just do:
after doing an io_uring_prep_cancel64() on the sqe. |
Beta Was this translation helpful? Give feedback.
-
Needs a new flag to match multiple cases, I'll do that next. Eg for matching both fd and op. What does work is doing op based cancel, if you can identify that uniquely with user_data && op. |
Beta Was this translation helpful? Give feedback.
-
Above branch has been updated now, with support for matching specific keys. So you can now decide if you want to match on user_data, fd, or opcode - and any combination of those. Eg if you want to match on opcode and fd, you'd set
in the cancel flags, basically you can combine any of these and use the new Also contains some cancel cleanup patches at the start, the last two requests are really the meat of it. |
Beta Was this translation helpful? Give feedback.
-
Series posted as well: https://lore.kernel.org/io-uring/[email protected]/ |
Beta Was this translation helpful? Give feedback.
-
nice, thanks! will test it today/over the weekend |
Beta Was this translation helpful? Give feedback.
-
Hi,
I wanted to cancel specifically a multishot recv SQE but encountered difficulty.
Currently, the following options are available for SQE cancellation:
io_uring_prep_cancel: With this method, my SQE would need to be identified by the user_data field. However, the problem is that my user_data values are not guaranteed to be unique. There is a possibility that I might end up canceling a different SQE that happens to have the same user_data value. To ensure uniqueness, I could make a memory allocation for each SQE and use the address of the allocation as the user_data value. However, I prefer to avoid unnecessary allocations if I can fit all the required data within the user_data field (up to 8 bytes), which can result in non-unique user_data values.
io_uring_prep_cancel_fd -- This method matches the SQE(s) based on the file descriptor used in the original request. The issue here is that I typically have other SQEs associated with the same file descriptor, such as send and recv operations on a TCP socket. And again, I might end up cancelling a different SQE than intended.
Feature request (my problem would be easily solved if we had any one of these features):
Thanks, let me know what your thoughts
Beta Was this translation helpful? Give feedback.
All reactions