summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-10-03 12:10:59 +0100
committerJens Axboe <axboe@kernel.dk>2021-10-03 07:06:49 -0600
commita987d7031d95d88f0fdb0301cd5187c5bf3fb889 (patch)
treea21dec4b7d29adf612a8209d195234f94bf3afa1
parent834496358870cb272f98cf22b3fe0307c83a526d (diff)
downloadliburing-a987d7031d95d88f0fdb0301cd5187c5bf3fb889.tar.gz
liburing-a987d7031d95d88f0fdb0301cd5187c5bf3fb889.tar.bz2
io_uring: test IORING_TIMEOUT_ETIME_SUCCESS
Make sure we don't fail links on ETIME when IORING_TIMEOUT_ETIME_SUCCESS is set. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/d1a5b6bdbcfa1ec6b5ca014248e12b3b1edb4e5d.1633259449.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/include/liburing/io_uring.h1
-rw-r--r--test/timeout.c67
2 files changed, 68 insertions, 0 deletions
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 7aa43fc..61683bd 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -162,6 +162,7 @@ enum {
#define IORING_TIMEOUT_BOOTTIME (1U << 2)
#define IORING_TIMEOUT_REALTIME (1U << 3)
#define IORING_LINK_TIMEOUT_UPDATE (1U << 4)
+#define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5)
#define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
#define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
/*
diff --git a/test/timeout.c b/test/timeout.c
index 775063f..f8ba973 100644
--- a/test/timeout.c
+++ b/test/timeout.c
@@ -1267,6 +1267,67 @@ static int test_timeout_link_cancel(void)
return 0;
}
+
+static int test_not_failing_links(void)
+{
+ struct io_uring ring;
+ struct io_uring_sqe *sqe;
+ struct io_uring_cqe *cqe;
+ struct __kernel_timespec ts;
+ int ret;
+
+ ret = io_uring_queue_init(8, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "ring create failed: %d\n", ret);
+ return 1;
+ }
+
+ msec_to_ts(&ts, 1);
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_timeout(sqe, &ts, 0, IORING_TIMEOUT_ETIME_SUCCESS);
+ sqe->user_data = 1;
+ sqe->flags |= IOSQE_IO_LINK;
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_nop(sqe);
+ sqe->user_data = 2;
+
+ ret = io_uring_submit(&ring);
+ if (ret != 2) {
+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
+ return 1;
+ }
+
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
+ return 1;
+ } else if (cqe->user_data == 1 && cqe->res == -EINVAL) {
+ fprintf(stderr, "ETIME_SUCCESS is not supported, skip\n");
+ goto done;
+ } else if (cqe->res != -ETIME || cqe->user_data != 1) {
+ fprintf(stderr, "timeout failed %i %i\n", cqe->res,
+ (int)cqe->user_data);
+ return 1;
+ }
+ io_uring_cqe_seen(&ring, cqe);
+
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
+ return 1;
+ } else if (cqe->res || cqe->user_data != 2) {
+ fprintf(stderr, "nop failed %i %i\n", cqe->res,
+ (int)cqe->user_data);
+ return 1;
+ }
+done:
+ io_uring_cqe_seen(&ring, cqe);
+ io_uring_queue_exit(&ring);
+ return 0;
+}
+
+
int main(int argc, char *argv[])
{
struct io_uring ring, sqpoll_ring;
@@ -1450,6 +1511,12 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_not_failing_links();
+ if (ret) {
+ fprintf(stderr, "test_not_failing_links failed\n");
+ return ret;
+ }
+
if (sqpoll)
io_uring_queue_exit(&sqpoll_ring);
return 0;