summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-27 04:10:52 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-27 04:10:52 -0600
commit40b44d24caf4b09343286a6b0882c8bbeadb3bbb (patch)
tree4775a0e45f957738ed2402cdd8eef191f57e84ca
parent2b5dc1da95a3487a3eafa9a814735c2c63637588 (diff)
downloadliburing-40b44d24caf4b09343286a6b0882c8bbeadb3bbb.tar.gz
liburing-40b44d24caf4b09343286a6b0882c8bbeadb3bbb.tar.bz2
Split up __io_uring_submit()
It really does two things: 1) Sync internal state with kernel ring on the SQ side 2) Submits the IO Move step 1 to __io_uring_flush_sq(), so we can use them separately from other functions. No intential functional changes in this commit. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/queue.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/queue.c b/src/queue.c
index 14ec1b7..54e30e8 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -156,17 +156,13 @@ static inline bool sq_ring_needs_enter(struct io_uring *ring, unsigned *flags)
}
/*
- * Submit sqes acquired from io_uring_get_sqe() to the kernel.
- *
- * Returns number of sqes submitted
+ * Sync internal state with kernel ring state on the SQ side
*/
-static int __io_uring_submit(struct io_uring *ring, unsigned wait_nr)
+static int __io_uring_flush_sq(struct io_uring *ring)
{
struct io_uring_sq *sq = &ring->sq;
const unsigned mask = *sq->kring_mask;
unsigned ktail, submitted, to_submit;
- unsigned flags;
- int ret;
if (sq->sqe_head == sq->sqe_tail)
return 0;
@@ -184,14 +180,26 @@ static int __io_uring_submit(struct io_uring *ring, unsigned wait_nr)
submitted++;
}
- if (!submitted)
- return 0;
-
/*
* Ensure that the kernel sees the SQE updates before it sees the tail
* update.
*/
- io_uring_smp_store_release(sq->ktail, ktail);
+ if (submitted)
+ io_uring_smp_store_release(sq->ktail, ktail);
+
+ return submitted;
+}
+
+/*
+ * Submit sqes acquired from io_uring_get_sqe() to the kernel.
+ *
+ * Returns number of sqes submitted
+ */
+static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
+ unsigned wait_nr)
+{
+ unsigned flags;
+ int ret;
flags = 0;
if (wait_nr || sq_ring_needs_enter(ring, &flags)) {
@@ -218,7 +226,13 @@ static int __io_uring_submit(struct io_uring *ring, unsigned wait_nr)
*/
int io_uring_submit(struct io_uring *ring)
{
- return __io_uring_submit(ring, 0);
+ int submitted;
+
+ submitted = __io_uring_flush_sq(ring);
+ if (submitted)
+ return __io_uring_submit(ring, submitted, 0);
+
+ return 0;
}
/*
@@ -228,7 +242,13 @@ int io_uring_submit(struct io_uring *ring)
*/
int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
- return __io_uring_submit(ring, wait_nr);
+ int submitted;
+
+ submitted = __io_uring_flush_sq(ring);
+ if (submitted)
+ return __io_uring_submit(ring, submitted, wait_nr);
+
+ return 0;
}
/*