diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-06-15 14:58:58 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-06-15 14:58:58 -0600 |
commit | 5e63866e719c47f13a0c43c90019fae912b328d8 (patch) | |
tree | dfac80a217582b75e6a8c1ce84decb8c4f79d9e8 | |
parent | 8f4b4af6dba4356366f4441797c51a0f25a62b64 (diff) | |
download | liburing-5e63866e719c47f13a0c43c90019fae912b328d8.tar.gz |
Add io_uring_prep_cancel64()
To keep things consistent between 2.1 and later versions of liburing,
make io_uring_prep_cancel() take a void * pointer again instead of a
__u64 type. Add io_uring_prep_cancel64() that takes a 64-bit type.
Link: https://github.com/axboe/liburing/discussions/601
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | man/io_uring_prep_cancel.3 | 11 | ||||
l--------- | man/io_uring_prep_cancel64.3 | 1 | ||||
-rw-r--r-- | src/include/liburing.h | 10 | ||||
-rw-r--r-- | test/accept.c | 2 | ||||
-rw-r--r-- | test/io-cancel.c | 6 |
5 files changed, 23 insertions, 7 deletions
diff --git a/man/io_uring_prep_cancel.3 b/man/io_uring_prep_cancel.3 index 25a500a..89c58c7 100644 --- a/man/io_uring_prep_cancel.3 +++ b/man/io_uring_prep_cancel.3 @@ -9,8 +9,12 @@ io_uring_prep_cancel \- prepare a cancelation request .nf .B #include <liburing.h> .PP +.BI "void io_uring_prep_cancel64(struct io_uring_sqe *" sqe "," +.BI " __u64 " user_data "," +.BI " int " flags ");" +.PP .BI "void io_uring_prep_cancel(struct io_uring_sqe *" sqe "," -.BI " __u64 " user_data "," +.BI " void *" user_data "," .BI " int " flags ");" .PP .BI "void io_uring_prep_cancel_fd(struct io_uring_sqe *" sqe "," @@ -29,6 +33,11 @@ For the .I flags argument, see below. +.BR io_uring_prep_cancel64 (3) +is identical to +.BR io_uring_prep_cancel (3) , +except it takes a 64-bit integer rather than a pointer type. + The cancelation request will attempt to find the previously issued request identified by .I user_data diff --git a/man/io_uring_prep_cancel64.3 b/man/io_uring_prep_cancel64.3 new file mode 120000 index 0000000..347db09 --- /dev/null +++ b/man/io_uring_prep_cancel64.3 @@ -0,0 +1 @@ +io_uring_prep_cancel.3
\ No newline at end of file diff --git a/src/include/liburing.h b/src/include/liburing.h index 8cba613..1c1b03e 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -538,14 +538,20 @@ static inline void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sq __io_uring_set_target_fixed_file(sqe, IORING_FILE_INDEX_ALLOC - 1); } -static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, - __u64 user_data, int flags) +static inline void io_uring_prep_cancel64(struct io_uring_sqe *sqe, + __u64 user_data, int flags) { io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, -1, NULL, 0, 0); sqe->addr = user_data; sqe->cancel_flags = (__u32) flags; } +static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, + void *user_data, int flags) +{ + io_uring_prep_cancel64(sqe, (__u64) (uintptr_t) user_data, flags); +} + static inline void io_uring_prep_cancel_fd(struct io_uring_sqe *sqe, int fd, unsigned int flags) { diff --git a/test/accept.c b/test/accept.c index 4e2f587..7bc6226 100644 --- a/test/accept.c +++ b/test/accept.c @@ -471,7 +471,7 @@ static int test_accept_cancel(unsigned usecs, unsigned int nr, bool multishot) for (i = 1; i <= nr; i++) { sqe = io_uring_get_sqe(&m_io_uring); - io_uring_prep_cancel(sqe, i, 0); + io_uring_prep_cancel64(sqe, i, 0); sqe->user_data = nr + i; ret = io_uring_submit(&m_io_uring); assert(ret == 1); diff --git a/test/io-cancel.c b/test/io-cancel.c index 89bb31a..d5e3ae9 100644 --- a/test/io-cancel.c +++ b/test/io-cancel.c @@ -128,7 +128,7 @@ static int start_cancel(struct io_uring *ring, int do_partial, int async_cancel) fprintf(stderr, "sqe get failed\n"); goto err; } - io_uring_prep_cancel(sqe, i + 1, 0); + io_uring_prep_cancel64(sqe, i + 1, 0); if (async_cancel) sqe->flags |= IOSQE_ASYNC; sqe->user_data = 0; @@ -246,7 +246,7 @@ static int test_dont_cancel_another_ring(void) fprintf(stderr, "%s: failed to get sqe\n", __FUNCTION__); return 1; } - io_uring_prep_cancel(sqe, 1, 0); + io_uring_prep_cancel64(sqe, 1, 0); sqe->user_data = 2; ret = io_uring_submit(&ring2); @@ -326,7 +326,7 @@ static int test_cancel_req_across_fork(void) fprintf(stderr, "%s: failed to get sqe\n", __FUNCTION__); return 1; } - io_uring_prep_cancel(sqe, 1, 0); + io_uring_prep_cancel64(sqe, 1, 0); sqe->user_data = 2; ret = io_uring_submit(&ring); |