@@ -5781,8 +5781,7 @@ static void io_commit_sqring(struct io_ring_ctx *ctx)
5781
5781
* used, it's important that those reads are done through READ_ONCE() to
5782
5782
* prevent a re-load down the line.
5783
5783
*/
5784
- static bool io_get_sqring (struct io_ring_ctx * ctx , struct io_kiocb * req ,
5785
- const struct io_uring_sqe * * sqe_ptr )
5784
+ static const struct io_uring_sqe * io_get_sqe (struct io_ring_ctx * ctx )
5786
5785
{
5787
5786
u32 * sq_array = ctx -> sq_array ;
5788
5787
unsigned head ;
@@ -5796,25 +5795,18 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct io_kiocb *req,
5796
5795
* though the application is the one updating it.
5797
5796
*/
5798
5797
head = READ_ONCE (sq_array [ctx -> cached_sq_head & ctx -> sq_mask ]);
5799
- if (likely (head < ctx -> sq_entries )) {
5800
- /*
5801
- * All io need record the previous position, if LINK vs DARIN,
5802
- * it can be used to mark the position of the first IO in the
5803
- * link list.
5804
- */
5805
- req -> sequence = ctx -> cached_sq_head ;
5806
- * sqe_ptr = & ctx -> sq_sqes [head ];
5807
- req -> opcode = READ_ONCE ((* sqe_ptr )-> opcode );
5808
- req -> user_data = READ_ONCE ((* sqe_ptr )-> user_data );
5809
- ctx -> cached_sq_head ++ ;
5810
- return true;
5811
- }
5798
+ if (likely (head < ctx -> sq_entries ))
5799
+ return & ctx -> sq_sqes [head ];
5812
5800
5813
5801
/* drop invalid entries */
5814
- ctx -> cached_sq_head ++ ;
5815
5802
ctx -> cached_sq_dropped ++ ;
5816
5803
WRITE_ONCE (ctx -> rings -> sq_dropped , ctx -> cached_sq_dropped );
5817
- return false;
5804
+ return NULL ;
5805
+ }
5806
+
5807
+ static inline void io_consume_sqe (struct io_ring_ctx * ctx )
5808
+ {
5809
+ ctx -> cached_sq_head ++ ;
5818
5810
}
5819
5811
5820
5812
static int io_submit_sqes (struct io_ring_ctx * ctx , unsigned int nr ,
@@ -5858,11 +5850,23 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
5858
5850
submitted = - EAGAIN ;
5859
5851
break ;
5860
5852
}
5861
- if (!io_get_sqring (ctx , req , & sqe )) {
5853
+ sqe = io_get_sqe (ctx );
5854
+ if (!sqe ) {
5862
5855
__io_req_do_free (req );
5856
+ io_consume_sqe (ctx );
5863
5857
break ;
5864
5858
}
5865
5859
5860
+ /*
5861
+ * All io need record the previous position, if LINK vs DARIN,
5862
+ * it can be used to mark the position of the first IO in the
5863
+ * link list.
5864
+ */
5865
+ req -> sequence = ctx -> cached_sq_head ;
5866
+ req -> opcode = READ_ONCE (sqe -> opcode );
5867
+ req -> user_data = READ_ONCE (sqe -> user_data );
5868
+ io_consume_sqe (ctx );
5869
+
5866
5870
/* will complete beyond this point, count as submitted */
5867
5871
submitted ++ ;
5868
5872
0 commit comments