Add __io_uring_submit_and_wait() helper
Used in two spots, instead of open coding it.
@@ -219,22 +219,27 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
return ret;
}
-/*
- * Submit sqes acquired from io_uring_get_sqe() to the kernel.
- *
- * Returns number of sqes submitted
- */
-int io_uring_submit(struct io_uring *ring)
+static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
int submitted;
submitted = __io_uring_flush_sq(ring);
if (submitted)
- return __io_uring_submit(ring, submitted, 0);
+ return __io_uring_submit(ring, submitted, wait_nr);
return 0;
}
+/*
+ * Submit sqes acquired from io_uring_get_sqe() to the kernel.
+ *
+ * Returns number of sqes submitted
+ */
+int io_uring_submit(struct io_uring *ring)
+{
+ return __io_uring_submit_and_wait(ring, 0);
+}
+
/*
* Like io_uring_submit(), but allows waiting for events as well.
*
@@ -242,13 +247,7 @@ int io_uring_submit(struct io_uring *ring)
*/
int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
{
- int submitted;
-
- submitted = __io_uring_flush_sq(ring);
- if (submitted)
- return __io_uring_submit(ring, submitted, wait_nr);
-
- return 0;
+ return __io_uring_submit_and_wait(ring, wait_nr);
}
/*
