diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-01-08 15:31:35 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-01-08 15:38:05 -0700 |
commit | 7f7a66e38543f36df6a64a4c3ba24ce4f4f04331 (patch) | |
tree | 92413056cbe4824e2a99e7a24073e9ad8a1d0d84 /test | |
parent | f47f24cea7d10abbc54e8dc8f184eca509dd77c1 (diff) |
Change API to provide io_uring struct abstraction
This is cleaner than having the app juggle an SQ and CQ ring,
just wrap them in struct io_uring and have the API always take
that. This means the app doesn't need to worry about the different
types of rings, and that we only need to pass in one argument
for setup/teardown.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test')
-rw-r--r-- | test/io_uring-test.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/test/io_uring-test.c b/test/io_uring-test.c index d945f48..1e47a26 100644 --- a/test/io_uring-test.c +++ b/test/io_uring-test.c @@ -14,8 +14,7 @@ int main(int argc, char *argv[]) { struct io_uring_params p; - struct io_uring_sq sq; - struct io_uring_cq cq; + struct io_uring ring; int i, fd, ring_fd, ret, pending, done; struct io_uring_iocb *iocb; struct io_uring_event *ev; @@ -30,7 +29,7 @@ int main(int argc, char *argv[]) memset(&p, 0, sizeof(p)); p.flags = IORING_SETUP_IOPOLL; - ring_fd = io_uring_queue_init(4, &p, NULL, &sq, &cq); + ring_fd = io_uring_queue_init(4, &p, NULL, &ring); if (ring_fd < 0) { fprintf(stderr, "queue_init: %s\n", strerror(-ring_fd)); return 1; @@ -47,7 +46,7 @@ int main(int argc, char *argv[]) offset = 0; do { - iocb = io_uring_get_iocb(&sq); + iocb = io_uring_get_iocb(&ring); if (!iocb) break; iocb->opcode = IORING_OP_READ; @@ -60,7 +59,7 @@ int main(int argc, char *argv[]) offset += 4096; } while (1); - ret = io_uring_submit(ring_fd, &sq); + ret = io_uring_submit(ring_fd, &ring); if (ret < 0) { fprintf(stderr, "io_uring_submit: %s\n", strerror(-ret)); return 1; @@ -70,7 +69,7 @@ int main(int argc, char *argv[]) pending = ret; for (i = 0; i < pending; i++) { ev = NULL; - ret = io_uring_get_completion(ring_fd, &cq, &ev); + ret = io_uring_get_completion(ring_fd, &ring, &ev); if (ret < 0) { fprintf(stderr, "io_uring_get_completion: %s\n", strerror(-ret)); return 1; @@ -85,6 +84,6 @@ int main(int argc, char *argv[]) printf("Submitted=%d, completed=%d\n", pending, done); close(fd); - io_uring_queue_exit(ring_fd, &sq, &cq); + io_uring_queue_exit(ring_fd, &ring); return 0; } |