From 3f78c17af13d7082d6e3f715487554ef13c3a14d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 27 Jan 2020 17:29:55 -0700 Subject: Update shared workqueue support and test case Signed-off-by: Jens Axboe --- src/include/liburing/io_uring.h | 2 +- test/shared-wq.c | 42 +++++++++-------------------------------- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index a2c9fe8..d4c7907 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -185,7 +185,7 @@ struct io_uring_params { __u32 sq_thread_cpu; __u32 sq_thread_idle; __u32 features; - __u32 wq_id; + __u32 wq_fd; __u32 resv[3]; struct io_sqring_offsets sq_off; struct io_cqring_offsets cq_off; diff --git a/test/shared-wq.c b/test/shared-wq.c index 7e913bb..b7c491c 100644 --- a/test/shared-wq.c +++ b/test/shared-wq.c @@ -10,26 +10,7 @@ #include "liburing.h" -static int test_attach_id_no_flag(void) -{ - struct io_uring_params p; - struct io_uring ring; - int ret; - - memset(&p, 0, sizeof(p)); - p.wq_id = 1; - ret = io_uring_queue_init_params(1, &ring, &p); - if (ret != -EINVAL) { - fprintf(stderr, "Attach to one: %d\n", ret); - goto err; - } - return 0; -err: - return 1; -} - - -static int test_attach_zero(void) +static int test_attach_invalid(int ringfd) { struct io_uring_params p; struct io_uring ring; @@ -37,7 +18,7 @@ static int test_attach_zero(void) memset(&p, 0, sizeof(p)); p.flags = IORING_SETUP_ATTACH_WQ; - p.wq_id = 0; + p.wq_fd = ringfd; ret = io_uring_queue_init_params(1, &ring, &p); if (ret != -EINVAL) { fprintf(stderr, "Attach to zero: %d\n", ret); @@ -48,7 +29,7 @@ err: return 1; } -static int test_attach(struct io_uring_params *org) +static int test_attach(int ringfd) { struct io_uring_params p; struct io_uring ring2; @@ -56,7 +37,7 @@ static int test_attach(struct io_uring_params *org) memset(&p, 0, sizeof(p)); p.flags = IORING_SETUP_ATTACH_WQ; - p.wq_id = org->wq_id; + p.wq_fd = ringfd; ret = io_uring_queue_init_params(1, &ring2, &p); if (ret == -EINVAL) { fprintf(stdout, "Sharing not supported, skipping\n"); @@ -65,13 +46,13 @@ static int test_attach(struct io_uring_params *org) fprintf(stderr, "Attach to id: %d\n", ret); goto err; } + sleep(30); io_uring_queue_exit(&ring2); return 0; err: return 1; } - int main(int argc, char *argv[]) { struct io_uring_params p; @@ -85,19 +66,14 @@ int main(int argc, char *argv[]) return 1; } - ret = test_attach_zero(); - if (ret) { - fprintf(stderr, "test_attach_zero failed\n"); - return ret; - } - - ret = test_attach_id_no_flag(); + /* stdout is definitely not an io_uring descriptor */ + ret = test_attach_invalid(2); if (ret) { - fprintf(stderr, "test_attach_id_no_flag failed\n"); + fprintf(stderr, "test_attach_invalid failed\n"); return ret; } - ret = test_attach(&p); + ret = test_attach(ring.ring_fd); if (ret) { fprintf(stderr, "test_attach failed\n"); return ret; -- cgit v1.2.3