@@ -1293,8 +1293,8 @@ static struct io_kiocb *io_get_fallback_req(struct io_ring_ctx *ctx)
1293
1293
return NULL ;
1294
1294
}
1295
1295
1296
- static struct io_kiocb * io_get_req (struct io_ring_ctx * ctx ,
1297
- struct io_submit_state * state )
1296
+ static struct io_kiocb * io_alloc_req (struct io_ring_ctx * ctx ,
1297
+ struct io_submit_state * state )
1298
1298
{
1299
1299
gfp_t gfp = GFP_KERNEL | __GFP_NOWARN ;
1300
1300
struct io_kiocb * req ;
@@ -1327,22 +1327,9 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
1327
1327
req = state -> reqs [state -> free_reqs ];
1328
1328
}
1329
1329
1330
- got_it :
1331
- req -> io = NULL ;
1332
- req -> file = NULL ;
1333
- req -> ctx = ctx ;
1334
- req -> flags = 0 ;
1335
- /* one is dropped after submission, the other at completion */
1336
- refcount_set (& req -> refs , 2 );
1337
- req -> task = NULL ;
1338
- req -> result = 0 ;
1339
- INIT_IO_WORK (& req -> work , io_wq_submit_work );
1340
1330
return req ;
1341
1331
fallback :
1342
- req = io_get_fallback_req (ctx );
1343
- if (req )
1344
- goto got_it ;
1345
- return NULL ;
1332
+ return io_get_fallback_req (ctx );
1346
1333
}
1347
1334
1348
1335
static inline void io_put_file (struct io_kiocb * req , struct file * file ,
@@ -5804,6 +5791,28 @@ static inline void io_consume_sqe(struct io_ring_ctx *ctx)
5804
5791
ctx -> cached_sq_head ++ ;
5805
5792
}
5806
5793
5794
+ static void io_init_req (struct io_ring_ctx * ctx , struct io_kiocb * req ,
5795
+ const struct io_uring_sqe * sqe )
5796
+ {
5797
+ /*
5798
+ * All io need record the previous position, if LINK vs DARIN,
5799
+ * it can be used to mark the position of the first IO in the
5800
+ * link list.
5801
+ */
5802
+ req -> sequence = ctx -> cached_sq_head ;
5803
+ req -> opcode = READ_ONCE (sqe -> opcode );
5804
+ req -> user_data = READ_ONCE (sqe -> user_data );
5805
+ req -> io = NULL ;
5806
+ req -> file = NULL ;
5807
+ req -> ctx = ctx ;
5808
+ req -> flags = 0 ;
5809
+ /* one is dropped after submission, the other at completion */
5810
+ refcount_set (& req -> refs , 2 );
5811
+ req -> task = NULL ;
5812
+ req -> result = 0 ;
5813
+ INIT_IO_WORK (& req -> work , io_wq_submit_work );
5814
+ }
5815
+
5807
5816
static int io_submit_sqes (struct io_ring_ctx * ctx , unsigned int nr ,
5808
5817
struct file * ring_file , int ring_fd ,
5809
5818
struct mm_struct * * mm , bool async )
@@ -5844,23 +5853,15 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
5844
5853
io_consume_sqe (ctx );
5845
5854
break ;
5846
5855
}
5847
- req = io_get_req (ctx , statep );
5856
+ req = io_alloc_req (ctx , statep );
5848
5857
if (unlikely (!req )) {
5849
5858
if (!submitted )
5850
5859
submitted = - EAGAIN ;
5851
5860
break ;
5852
5861
}
5853
5862
5854
- /*
5855
- * All io need record the previous position, if LINK vs DARIN,
5856
- * it can be used to mark the position of the first IO in the
5857
- * link list.
5858
- */
5859
- req -> sequence = ctx -> cached_sq_head ;
5860
- req -> opcode = READ_ONCE (sqe -> opcode );
5861
- req -> user_data = READ_ONCE (sqe -> user_data );
5863
+ io_init_req (ctx , req , sqe );
5862
5864
io_consume_sqe (ctx );
5863
-
5864
5865
/* will complete beyond this point, count as submitted */
5865
5866
submitted ++ ;
5866
5867
0 commit comments