summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-19 09:55:18 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-19 09:55:18 -0600
commitefb4e867013f64df7db92a3dee9f9d497f7de3b6 (patch)
tree2b142a5479ffa148cfb49fe14f3bae7661ba6f52
parentefb39e105afdb4dd5c0f1e964720cfa3cdcceb18 (diff)
downloadliburing-efb4e867013f64df7db92a3dee9f9d497f7de3b6.tar.gz
liburing-efb4e867013f64df7db92a3dee9f9d497f7de3b6.tar.bz2
Remove TIMEOUT code
We'll rework it for the final version, kill the early version test case and liburing addition. This reverts commits: efb39e105afdb4dd5c0f1e964720cfa3cdcceb18 e4269d2c10586c03786df24d6382da99a956f03c 4652762d5be96e08a0ff8194de1e6f6d8127cee5 f102231b0fdbfe8587efda0b24c79a69ee4d8ba7 Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/include/liburing.h7
-rw-r--r--src/include/liburing/io_uring.h1
-rw-r--r--test/Makefile6
-rw-r--r--test/timeout.c174
4 files changed, 2 insertions, 186 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 5448771..c4189b1 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -10,7 +10,6 @@ extern "C" {
#include <signal.h>
#include <string.h>
#include <inttypes.h>
-#include <time.h>
#include "liburing/compat.h"
#include "liburing/io_uring.h"
#include "liburing/barrier.h"
@@ -235,12 +234,6 @@ static inline void io_uring_prep_nop(struct io_uring_sqe *sqe)
sqe->opcode = IORING_OP_NOP;
}
-static inline void io_uring_prep_timeout(struct io_uring_sqe *sqe,
- struct timespec *ts)
-{
- io_uring_prep_rw(IORING_OP_TIMEOUT, sqe, 0, ts, 1, 0);
-}
-
#ifdef __cplusplus
}
#endif
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index cf3101d..96ee9d9 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -61,7 +61,6 @@ struct io_uring_sqe {
#define IORING_OP_SYNC_FILE_RANGE 8
#define IORING_OP_SENDMSG 9
#define IORING_OP_RECVMSG 10
-#define IORING_OP_TIMEOUT 11
/*
* sqe->fsync_flags
diff --git a/test/Makefile b/test/Makefile
index 8bd96c1..2770219 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -4,7 +4,7 @@ override CFLAGS += -Wall -D_GNU_SOURCE -L../src/ -I../src/include/
all_targets += poll poll-cancel ring-leak fsync io_uring_setup io_uring_register \
io_uring_enter nop sq-full cq-full 35fa71a030ca-test \
917257daa0fe-test b19062a56726-test eeed8b54e0df-test link \
- send_recvmsg a4c0b3decb33-test 500f9fbadef8-test timeout
+ send_recvmsg a4c0b3decb33-test 500f9fbadef8-test
all: $(all_targets)
@@ -12,7 +12,7 @@ test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \
io_uring_register.c io_uring_enter.c nop.c sq-full.c cq-full.c \
35fa71a030ca-test.c 917257daa0fe-test.c b19062a56726-test.c \
eeed8b54e0df-test.c link.c send_recvmsg.c a4c0b3decb33-test.c \
- 500f9fbadef8-test.c timeout.c
+ 500f9fbadef8-test.c
test_objs := $(patsubst %.c,%.ol,$(test_srcs))
@@ -52,8 +52,6 @@ a4c0b3decb33-test: a4c0b3decb33-test.c
$(CC) $(CFLAGS) -o $@ a4c0b3decb33-test.c -luring
500f9fbadef8-test: 500f9fbadef8-test.c
$(CC) $(CFLAGS) -o $@ 500f9fbadef8-test.c -luring
-timeout: timeout.c
- $(CC) $(CFLAGS) -o $@ timeout.c -luring
clean:
rm -f $(all_targets) $(test_objs)
diff --git a/test/timeout.c b/test/timeout.c
deleted file mode 100644
index 8e40ea8..0000000
--- a/test/timeout.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Description: run various timeout tests
- *
- */
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/time.h>
-
-#include "liburing.h"
-
-#define TIMEOUT_MSEC 1000
-
-static unsigned long long mtime_since(const struct timeval *s,
- const struct timeval *e)
-{
- long long sec, usec;
-
- sec = e->tv_sec - s->tv_sec;
- usec = (e->tv_usec - s->tv_usec);
- if (sec > 0 && usec < 0) {
- sec--;
- usec += 1000000;
- }
-
- sec *= 1000;
- usec /= 1000;
- return sec + usec;
-}
-
-static unsigned long long mtime_since_now(struct timeval *tv)
-{
- struct timeval end;
-
- gettimeofday(&end, NULL);
- return mtime_since(tv, &end);
-}
-
-/*
- * Test that we return to userspace if a timeout triggers, even if we
- * don't satisfy the number of events asked for.
- */
-static int test_single_timeout_many(struct io_uring *ring)
-{
- struct io_uring_cqe *cqe;
- struct io_uring_sqe *sqe;
- unsigned long long exp;
- struct timespec ts;
- struct timeval tv;
- int ret;
-
- sqe = io_uring_get_sqe(ring);
- if (!sqe) {
- printf("get sqe failed\n");
- goto err;
- }
-
- ts.tv_sec = TIMEOUT_MSEC / 1000;
- ts.tv_nsec = 0;
- io_uring_prep_timeout(sqe, &ts);
-
- ret = io_uring_submit(ring);
- if (ret <= 0) {
- printf("sqe submit failed: %d\n", ret);
- goto err;
- }
-
- gettimeofday(&tv, NULL);
- ret = io_uring_enter(ring->ring_fd, 0, 4, IORING_ENTER_GETEVENTS, NULL);
- if (ret < 0) {
- printf("io_uring_enter %d\n", ret);
- goto err;
- }
-
- ret = io_uring_wait_cqe(ring, &cqe);
- if (ret < 0) {
- printf("wait completion %d\n", ret);
- goto err;
- }
- if (cqe->res == -EINVAL)
- printf("Timeout not supported, ignored\n");
- else if (cqe->res != 0) {
- printf("Timeout: %s\n", strerror(-cqe->res));
- goto err;
- }
- io_uring_cqe_seen(ring, cqe);
-
- exp = mtime_since_now(&tv);
- if (exp >= TIMEOUT_MSEC / 2 && exp <= (TIMEOUT_MSEC * 3) / 2)
- return 0;
- printf("Timeout seems wonky (got %llu)\n", exp);
-err:
- return 1;
-}
-
-/*
- * Test single timeout waking us up
- */
-static int test_single_timeout(struct io_uring *ring)
-{
- struct io_uring_cqe *cqe;
- struct io_uring_sqe *sqe;
- unsigned long long exp;
- struct timespec ts;
- struct timeval tv;
- int ret;
-
- sqe = io_uring_get_sqe(ring);
- if (!sqe) {
- printf("get sqe failed\n");
- goto err;
- }
-
- ts.tv_sec = TIMEOUT_MSEC / 1000;
- ts.tv_nsec = 0;
- io_uring_prep_timeout(sqe, &ts);
-
- ret = io_uring_submit(ring);
- if (ret <= 0) {
- printf("sqe submit failed: %d\n", ret);
- goto err;
- }
-
- gettimeofday(&tv, NULL);
- ret = io_uring_wait_cqe(ring, &cqe);
- if (ret < 0) {
- printf("wait completion %d\n", ret);
- goto err;
- }
- if (cqe->res == -EINVAL)
- printf("Timeout not supported, ignored\n");
- else if (cqe->res != 0) {
- printf("Timeout: %s\n", strerror(-cqe->res));
- goto err;
- }
- io_uring_cqe_seen(ring, cqe);
-
- exp = mtime_since_now(&tv);
- if (exp >= TIMEOUT_MSEC / 2 && exp <= (TIMEOUT_MSEC * 3) / 2)
- return 0;
- printf("Timeout seems wonky (got %llu)\n", exp);
-err:
- return 1;
-}
-
-int main(int argc, char *argv[])
-{
- struct io_uring ring;
- int ret;
-
- ret = io_uring_queue_init(8, &ring, 0);
- if (ret) {
- printf("ring setup failed\n");
- return 1;
-
- }
-
- ret = test_single_timeout(&ring);
- if (ret) {
- printf("test_single_timeout failed\n");
- return ret;
- }
-
- ret = test_single_timeout_many(&ring);
- if (ret) {
- printf("test_single_timeout_many failed\n");
- return ret;
- }
-
- return 0;
-}