From 39e0ebd4fc66046bf733a47aaa899a556093ebc6 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 18 Apr 2019 08:32:06 -0600 Subject: Rename completion helpers We have io_uring_get_sqe() on the submission side, yet the completion side is named _completion. Rename as follows: io_uring_get_completion() io_uring_peek_cqe() iO_uring_wait_completion() io_uring_wait_cqe() This better tells the user what the _get variant does by calling it _peek instead, and we move to using _cqe() as the postfix instead of _completion. Signed-off-by: Jens Axboe --- examples/io_uring-cp.c | 6 +++--- examples/io_uring-test.c | 4 ++-- src/liburing.h | 6 +++--- src/liburing.map | 4 ++-- src/queue.c | 20 ++++++++++---------- test/cq-full.c | 2 +- test/fsync.c | 4 ++-- test/io_uring_enter.c | 4 ++-- test/io_uring_register.c | 6 +++--- test/nop.c | 4 ++-- test/poll-cancel.c | 4 ++-- test/poll.c | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/examples/io_uring-cp.c b/examples/io_uring-cp.c index f704ff6..1dd20fc 100644 --- a/examples/io_uring-cp.c +++ b/examples/io_uring-cp.c @@ -161,12 +161,12 @@ static int copy_file(struct io_uring *ring, off_t insize) struct io_data *data; if (!got_comp) { - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); got_comp = 1; } else - ret = io_uring_get_completion(ring, &cqe); + ret = io_uring_peek_cqe(ring, &cqe); if (ret < 0) { - fprintf(stderr, "io_uring_get_completion: %s\n", + fprintf(stderr, "io_uring_peek_cqe: %s\n", strerror(-ret)); return 1; } diff --git a/examples/io_uring-test.c b/examples/io_uring-test.c index fe0098c..bbac3a7 100644 --- a/examples/io_uring-test.c +++ b/examples/io_uring-test.c @@ -67,9 +67,9 @@ int main(int argc, char *argv[]) done = 0; pending = ret; for (i = 0; i < pending; i++) { - ret = io_uring_wait_completion(&ring, &cqe); + ret = io_uring_wait_cqe(&ring, &cqe); if (ret < 0) { - fprintf(stderr, "io_uring_get_completion: %s\n", strerror(-ret)); + fprintf(stderr, "io_uring_wait_cqe: %s\n", strerror(-ret)); return 1; } diff --git a/src/liburing.h b/src/liburing.h index 158239a..a8d77e1 100644 --- a/src/liburing.h +++ b/src/liburing.h @@ -61,15 +61,15 @@ extern int io_uring_queue_init(unsigned entries, struct io_uring *ring, extern int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring); extern void io_uring_queue_exit(struct io_uring *ring); -extern int io_uring_get_completion(struct io_uring *ring, +extern int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr); -extern int io_uring_wait_completion(struct io_uring *ring, +extern int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr); extern int io_uring_submit(struct io_uring *ring); extern struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring); /* - * Must be called after io_uring_{get,wait}_completion() after the cqe has + * Must be called after io_uring_{peek,wait}_cqe() after the cqe has * been processed by the application. */ static inline void io_uring_cqe_seen(struct io_uring *ring, diff --git a/src/liburing.map b/src/liburing.map index 67e5171..06f5002 100644 --- a/src/liburing.map +++ b/src/liburing.map @@ -2,8 +2,8 @@ LIBURING_0.1 { global: io_uring_queue_init; io_uring_queue_exit; - io_uring_get_completion; - io_uring_wait_completion; + io_uring_peek_cqe; + io_uring_wait_cqe; io_uring_submit; io_uring_get_sqe; local: diff --git a/src/queue.c b/src/queue.c index 72b3af2..4b4fea9 100644 --- a/src/queue.c +++ b/src/queue.c @@ -10,8 +10,8 @@ #include "liburing.h" #include "barrier.h" -static int __io_uring_get_completion(struct io_uring *ring, - struct io_uring_cqe **cqe_ptr, int wait) +static int __io_uring_get_cqe(struct io_uring *ring, + struct io_uring_cqe **cqe_ptr, int wait) { struct io_uring_cq *cq = &ring->cq; const unsigned mask = *cq->kring_mask; @@ -45,21 +45,21 @@ static int __io_uring_get_completion(struct io_uring *ring, } /* - * Return an IO completion, if one is readily available + * Return an IO completion, if one is readily available. Returns 0 with + * cqe_ptr filled in on success, -errno on failure. */ -int io_uring_get_completion(struct io_uring *ring, - struct io_uring_cqe **cqe_ptr) +int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { - return __io_uring_get_completion(ring, cqe_ptr, 0); + return __io_uring_get_cqe(ring, cqe_ptr, 0); } /* - * Return an IO completion, waiting for it if necessary + * Return an IO completion, waiting for it if necessary. Returns 0 with + * cqe_ptr filled in on success, -errno on failure. */ -int io_uring_wait_completion(struct io_uring *ring, - struct io_uring_cqe **cqe_ptr) +int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr) { - return __io_uring_get_completion(ring, cqe_ptr, 1); + return __io_uring_get_cqe(ring, cqe_ptr, 1); } /* diff --git a/test/cq-full.c b/test/cq-full.c index 42021bd..82c5a65 100644 --- a/test/cq-full.c +++ b/test/cq-full.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) i = 0; do { - ret = io_uring_get_completion(&ring, &cqe); + ret = io_uring_peek_cqe(&ring, &cqe); if (ret < 0) { printf("wait completion %d\n", ret); goto err; diff --git a/test/fsync.c b/test/fsync.c index f127b17..de28c2c 100644 --- a/test/fsync.c +++ b/test/fsync.c @@ -39,7 +39,7 @@ static int test_single_fsync(struct io_uring *ring) goto err; } - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { printf("wait completion %d\n", ret); goto err; @@ -107,7 +107,7 @@ static int test_barrier_fsync(struct io_uring *ring) } for (i = 0; i < 5; i++) { - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { printf("child: wait completion %d\n", ret); goto err; diff --git a/test/io_uring_enter.c b/test/io_uring_enter.c index 51ab8bb..d6e407e 100644 --- a/test/io_uring_enter.c +++ b/test/io_uring_enter.c @@ -146,9 +146,9 @@ reap_events(struct io_uring *ring, unsigned nr) printf("Reaping %u I/Os\n", nr); gettimeofday(&start, NULL); while (left) { - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { - printf("io_uring_wait_completion returned %d\n", ret); + printf("io_uring_wait_cqe returned %d\n", ret); printf("expected success\n"); exit(1); } diff --git a/test/io_uring_register.c b/test/io_uring_register.c index 61ea64e..0ffdee7 100644 --- a/test/io_uring_register.c +++ b/test/io_uring_register.c @@ -423,14 +423,14 @@ ioring_poll(struct io_uring *ring, int fd, int fixed) return 1; } - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { - printf("io_uring_wait_completion failed with %d\n", ret); + printf("io_uring_wait_cqe failed with %d\n", ret); return 1; } ret = 0; if (cqe->res != POLLOUT) { - printf("io_uring_wait_completion: expected 0x%.8x, got 0x%.8x\n", + printf("io_uring_wait_cqe: expected 0x%.8x, got 0x%.8x\n", POLLOUT, cqe->res); ret = 1; } diff --git a/test/nop.c b/test/nop.c index 7fe2455..8e6bfb0 100644 --- a/test/nop.c +++ b/test/nop.c @@ -31,7 +31,7 @@ static int test_single_nop(struct io_uring *ring) goto err; } - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { printf("wait completion %d\n", ret); goto err; @@ -71,7 +71,7 @@ static int test_barrier_nop(struct io_uring *ring) } for (i = 0; i < 8; i++) { - ret = io_uring_wait_completion(ring, &cqe); + ret = io_uring_wait_cqe(ring, &cqe); if (ret < 0) { printf("wait completion %d\n", ret); goto err; diff --git a/test/poll-cancel.c b/test/poll-cancel.c index c318a61..19efc5f 100644 --- a/test/poll-cancel.c +++ b/test/poll-cancel.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) return 1; } - ret = io_uring_wait_completion(&ring, &cqe); + ret = io_uring_wait_cqe(&ring, &cqe); if (ret < 0) { printf("child: get cqe failed\n"); return 1; @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) } io_uring_cqe_seen(&ring, cqe); - ret = io_uring_wait_completion(&ring, &cqe); + ret = io_uring_wait_cqe(&ring, &cqe); if (ret < 0) { printf("parent: get failed\n"); return 1; diff --git a/test/poll.c b/test/poll.c index 02d7899..d22d9c5 100644 --- a/test/poll.c +++ b/test/poll.c @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) } do { - ret = io_uring_wait_completion(&ring, &cqe); + ret = io_uring_wait_cqe(&ring, &cqe); if (ret < 0) { printf("child: wait completion %d\n", ret); break; -- cgit