summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/liburing.h20
-rw-r--r--src/queue.c9
2 files changed, 20 insertions, 9 deletions
diff --git a/src/liburing.h b/src/liburing.h
index a544fa5..158239a 100644
--- a/src/liburing.h
+++ b/src/liburing.h
@@ -6,6 +6,7 @@
#include <inttypes.h>
#include "compat.h"
#include "io_uring.h"
+#include "barrier.h"
/*
* Library interface to io_uring
@@ -68,6 +69,25 @@ 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
+ * been processed by the application.
+ */
+static inline void io_uring_cqe_seen(struct io_uring *ring,
+ struct io_uring_cqe *cqe)
+{
+ if (cqe) {
+ struct io_uring_cq *cq = &ring->cq;
+
+ (*cq->khead)++;
+ /*
+ * Ensure that the kernel sees our new head, the kernel has
+ * the matching read barrier.
+ */
+ write_barrier();
+ }
+}
+
+/*
* Command prep helpers
*/
static inline void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data)
diff --git a/src/queue.c b/src/queue.c
index 6767790..72b3af2 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -41,15 +41,6 @@ static int __io_uring_get_completion(struct io_uring *ring,
return -errno;
} while (1);
- if (*cqe_ptr) {
- *cq->khead = head + 1;
- /*
- * Ensure that the kernel sees our new head, the kernel has
- * the matching read barrier.
- */
- write_barrier();
- }
-
return 0;
}