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 <axboe@kernel.dk>
This commit is contained in:
Jens Axboe
2019-04-18 08:32:06 -06:00
parent 4916320ec3
commit 39e0ebd4fc
12 changed files with 33 additions and 33 deletions

View File

@@ -161,12 +161,12 @@ static int copy_file(struct io_uring *ring, off_t insize)
struct io_data *data; struct io_data *data;
if (!got_comp) { if (!got_comp) {
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
got_comp = 1; got_comp = 1;
} else } else
ret = io_uring_get_completion(ring, &cqe); ret = io_uring_peek_cqe(ring, &cqe);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "io_uring_get_completion: %s\n", fprintf(stderr, "io_uring_peek_cqe: %s\n",
strerror(-ret)); strerror(-ret));
return 1; return 1;
} }

View File

@@ -67,9 +67,9 @@ int main(int argc, char *argv[])
done = 0; done = 0;
pending = ret; pending = ret;
for (i = 0; i < pending; i++) { for (i = 0; i < pending; i++) {
ret = io_uring_wait_completion(&ring, &cqe); ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) { 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; return 1;
} }

View File

@@ -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, extern int io_uring_queue_mmap(int fd, struct io_uring_params *p,
struct io_uring *ring); struct io_uring *ring);
extern void io_uring_queue_exit(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); 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); struct io_uring_cqe **cqe_ptr);
extern int io_uring_submit(struct io_uring *ring); extern int io_uring_submit(struct io_uring *ring);
extern struct io_uring_sqe *io_uring_get_sqe(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. * been processed by the application.
*/ */
static inline void io_uring_cqe_seen(struct io_uring *ring, static inline void io_uring_cqe_seen(struct io_uring *ring,

View File

@@ -2,8 +2,8 @@ LIBURING_0.1 {
global: global:
io_uring_queue_init; io_uring_queue_init;
io_uring_queue_exit; io_uring_queue_exit;
io_uring_get_completion; io_uring_peek_cqe;
io_uring_wait_completion; io_uring_wait_cqe;
io_uring_submit; io_uring_submit;
io_uring_get_sqe; io_uring_get_sqe;
local: local:

View File

@@ -10,8 +10,8 @@
#include "liburing.h" #include "liburing.h"
#include "barrier.h" #include "barrier.h"
static int __io_uring_get_completion(struct io_uring *ring, static int __io_uring_get_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr, int wait) struct io_uring_cqe **cqe_ptr, int wait)
{ {
struct io_uring_cq *cq = &ring->cq; struct io_uring_cq *cq = &ring->cq;
const unsigned mask = *cq->kring_mask; 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, int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
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, int io_uring_wait_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
struct io_uring_cqe **cqe_ptr)
{ {
return __io_uring_get_completion(ring, cqe_ptr, 1); return __io_uring_get_cqe(ring, cqe_ptr, 1);
} }
/* /*

View File

@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
i = 0; i = 0;
do { do {
ret = io_uring_get_completion(&ring, &cqe); ret = io_uring_peek_cqe(&ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("wait completion %d\n", ret); printf("wait completion %d\n", ret);
goto err; goto err;

View File

@@ -39,7 +39,7 @@ static int test_single_fsync(struct io_uring *ring)
goto err; goto err;
} }
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("wait completion %d\n", ret); printf("wait completion %d\n", ret);
goto err; goto err;
@@ -107,7 +107,7 @@ static int test_barrier_fsync(struct io_uring *ring)
} }
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("child: wait completion %d\n", ret); printf("child: wait completion %d\n", ret);
goto err; goto err;

View File

@@ -146,9 +146,9 @@ reap_events(struct io_uring *ring, unsigned nr)
printf("Reaping %u I/Os\n", nr); printf("Reaping %u I/Os\n", nr);
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
while (left) { while (left) {
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) { 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"); printf("expected success\n");
exit(1); exit(1);
} }

View File

@@ -423,14 +423,14 @@ ioring_poll(struct io_uring *ring, int fd, int fixed)
return 1; return 1;
} }
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) { 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; return 1;
} }
ret = 0; ret = 0;
if (cqe->res != POLLOUT) { 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); POLLOUT, cqe->res);
ret = 1; ret = 1;
} }

View File

@@ -31,7 +31,7 @@ static int test_single_nop(struct io_uring *ring)
goto err; goto err;
} }
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("wait completion %d\n", ret); printf("wait completion %d\n", ret);
goto err; goto err;
@@ -71,7 +71,7 @@ static int test_barrier_nop(struct io_uring *ring)
} }
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
ret = io_uring_wait_completion(ring, &cqe); ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("wait completion %d\n", ret); printf("wait completion %d\n", ret);
goto err; goto err;

View File

@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
ret = io_uring_wait_completion(&ring, &cqe); ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("child: get cqe failed\n"); printf("child: get cqe failed\n");
return 1; return 1;
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
} }
io_uring_cqe_seen(&ring, cqe); io_uring_cqe_seen(&ring, cqe);
ret = io_uring_wait_completion(&ring, &cqe); ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("parent: get failed\n"); printf("parent: get failed\n");
return 1; return 1;

View File

@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
} }
do { do {
ret = io_uring_wait_completion(&ring, &cqe); ret = io_uring_wait_cqe(&ring, &cqe);
if (ret < 0) { if (ret < 0) {
printf("child: wait completion %d\n", ret); printf("child: wait completion %d\n", ret);
break; break;