@@ -331,8 +331,8 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
331331}
332332
333333static struct request * blk_mq_get_request (struct request_queue * q ,
334- struct bio * bio , unsigned int op ,
335- struct blk_mq_alloc_data * data )
334+ struct bio * bio ,
335+ struct blk_mq_alloc_data * data )
336336{
337337 struct elevator_queue * e = q -> elevator ;
338338 struct request * rq ;
@@ -346,8 +346,9 @@ static struct request *blk_mq_get_request(struct request_queue *q,
346346 put_ctx_on_error = true;
347347 }
348348 if (likely (!data -> hctx ))
349- data -> hctx = blk_mq_map_queue (q , data -> ctx -> cpu );
350- if (op & REQ_NOWAIT )
349+ data -> hctx = blk_mq_map_queue (q , data -> cmd_flags ,
350+ data -> ctx -> cpu );
351+ if (data -> cmd_flags & REQ_NOWAIT )
351352 data -> flags |= BLK_MQ_REQ_NOWAIT ;
352353
353354 if (e ) {
@@ -358,9 +359,10 @@ static struct request *blk_mq_get_request(struct request_queue *q,
358359 * dispatch list. Don't include reserved tags in the
359360 * limiting, as it isn't useful.
360361 */
361- if (!op_is_flush (op ) && e -> type -> ops .limit_depth &&
362+ if (!op_is_flush (data -> cmd_flags ) &&
363+ e -> type -> ops .limit_depth &&
362364 !(data -> flags & BLK_MQ_REQ_RESERVED ))
363- e -> type -> ops .limit_depth (op , data );
365+ e -> type -> ops .limit_depth (data -> cmd_flags , data );
364366 } else {
365367 blk_mq_tag_busy (data -> hctx );
366368 }
@@ -375,8 +377,8 @@ static struct request *blk_mq_get_request(struct request_queue *q,
375377 return NULL ;
376378 }
377379
378- rq = blk_mq_rq_ctx_init (data , tag , op );
379- if (!op_is_flush (op )) {
380+ rq = blk_mq_rq_ctx_init (data , tag , data -> cmd_flags );
381+ if (!op_is_flush (data -> cmd_flags )) {
380382 rq -> elv .icq = NULL ;
381383 if (e && e -> type -> ops .prepare_request ) {
382384 if (e -> type -> icq_cache && rq_ioc (bio ))
@@ -393,15 +395,15 @@ static struct request *blk_mq_get_request(struct request_queue *q,
393395struct request * blk_mq_alloc_request (struct request_queue * q , unsigned int op ,
394396 blk_mq_req_flags_t flags )
395397{
396- struct blk_mq_alloc_data alloc_data = { .flags = flags };
398+ struct blk_mq_alloc_data alloc_data = { .flags = flags , . cmd_flags = op };
397399 struct request * rq ;
398400 int ret ;
399401
400402 ret = blk_queue_enter (q , flags );
401403 if (ret )
402404 return ERR_PTR (ret );
403405
404- rq = blk_mq_get_request (q , NULL , op , & alloc_data );
406+ rq = blk_mq_get_request (q , NULL , & alloc_data );
405407 blk_queue_exit (q );
406408
407409 if (!rq )
@@ -419,7 +421,7 @@ EXPORT_SYMBOL(blk_mq_alloc_request);
419421struct request * blk_mq_alloc_request_hctx (struct request_queue * q ,
420422 unsigned int op , blk_mq_req_flags_t flags , unsigned int hctx_idx )
421423{
422- struct blk_mq_alloc_data alloc_data = { .flags = flags };
424+ struct blk_mq_alloc_data alloc_data = { .flags = flags , . cmd_flags = op };
423425 struct request * rq ;
424426 unsigned int cpu ;
425427 int ret ;
@@ -452,7 +454,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
452454 cpu = cpumask_first_and (alloc_data .hctx -> cpumask , cpu_online_mask );
453455 alloc_data .ctx = __blk_mq_get_ctx (q , cpu );
454456
455- rq = blk_mq_get_request (q , NULL , op , & alloc_data );
457+ rq = blk_mq_get_request (q , NULL , & alloc_data );
456458 blk_queue_exit (q );
457459
458460 if (!rq )
@@ -466,7 +468,7 @@ static void __blk_mq_free_request(struct request *rq)
466468{
467469 struct request_queue * q = rq -> q ;
468470 struct blk_mq_ctx * ctx = rq -> mq_ctx ;
469- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (q , ctx -> cpu );
471+ struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (q , rq -> cmd_flags , ctx -> cpu );
470472 const int sched_tag = rq -> internal_tag ;
471473
472474 blk_pm_mark_last_busy (rq );
@@ -483,7 +485,7 @@ void blk_mq_free_request(struct request *rq)
483485 struct request_queue * q = rq -> q ;
484486 struct elevator_queue * e = q -> elevator ;
485487 struct blk_mq_ctx * ctx = rq -> mq_ctx ;
486- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (q , ctx -> cpu );
488+ struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (q , rq -> cmd_flags , ctx -> cpu );
487489
488490 if (rq -> rq_flags & RQF_ELVPRIV ) {
489491 if (e && e -> type -> ops .finish_request )
@@ -977,8 +979,9 @@ bool blk_mq_get_driver_tag(struct request *rq)
977979{
978980 struct blk_mq_alloc_data data = {
979981 .q = rq -> q ,
980- .hctx = blk_mq_map_queue (rq -> q , rq -> mq_ctx -> cpu ),
982+ .hctx = blk_mq_map_queue (rq -> q , rq -> cmd_flags , rq -> mq_ctx -> cpu ),
981983 .flags = BLK_MQ_REQ_NOWAIT ,
984+ .cmd_flags = rq -> cmd_flags ,
982985 };
983986 bool shared ;
984987
@@ -1142,7 +1145,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
11421145
11431146 rq = list_first_entry (list , struct request , queuelist );
11441147
1145- hctx = blk_mq_map_queue (rq -> q , rq -> mq_ctx -> cpu );
1148+ hctx = blk_mq_map_queue (rq -> q , rq -> cmd_flags , rq -> mq_ctx -> cpu );
11461149 if (!got_budget && !blk_mq_get_dispatch_budget (hctx ))
11471150 break ;
11481151
@@ -1573,7 +1576,8 @@ void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
15731576void blk_mq_request_bypass_insert (struct request * rq , bool run_queue )
15741577{
15751578 struct blk_mq_ctx * ctx = rq -> mq_ctx ;
1576- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (rq -> q , ctx -> cpu );
1579+ struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (rq -> q , rq -> cmd_flags ,
1580+ ctx -> cpu );
15771581
15781582 spin_lock (& hctx -> lock );
15791583 list_add_tail (& rq -> queuelist , & hctx -> dispatch );
@@ -1783,7 +1787,8 @@ blk_status_t blk_mq_request_issue_directly(struct request *rq)
17831787 int srcu_idx ;
17841788 blk_qc_t unused_cookie ;
17851789 struct blk_mq_ctx * ctx = rq -> mq_ctx ;
1786- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (rq -> q , ctx -> cpu );
1790+ struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (rq -> q , rq -> cmd_flags ,
1791+ ctx -> cpu );
17871792
17881793 hctx_lock (hctx , & srcu_idx );
17891794 ret = __blk_mq_try_issue_directly (hctx , rq , & unused_cookie , true);
@@ -1817,7 +1822,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
18171822{
18181823 const int is_sync = op_is_sync (bio -> bi_opf );
18191824 const int is_flush_fua = op_is_flush (bio -> bi_opf );
1820- struct blk_mq_alloc_data data = { .flags = 0 };
1825+ struct blk_mq_alloc_data data = { .flags = 0 , . cmd_flags = bio -> bi_opf };
18211826 struct request * rq ;
18221827 unsigned int request_count = 0 ;
18231828 struct blk_plug * plug ;
@@ -1840,7 +1845,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
18401845
18411846 rq_qos_throttle (q , bio , NULL );
18421847
1843- rq = blk_mq_get_request (q , bio , bio -> bi_opf , & data );
1848+ rq = blk_mq_get_request (q , bio , & data );
18441849 if (unlikely (!rq )) {
18451850 rq_qos_cleanup (q , bio );
18461851 if (bio -> bi_opf & REQ_NOWAIT )
@@ -1909,6 +1914,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
19091914
19101915 if (same_queue_rq ) {
19111916 data .hctx = blk_mq_map_queue (q ,
1917+ same_queue_rq -> cmd_flags ,
19121918 same_queue_rq -> mq_ctx -> cpu );
19131919 blk_mq_try_issue_directly (data .hctx , same_queue_rq ,
19141920 & cookie );
@@ -2263,7 +2269,7 @@ static void blk_mq_init_cpu_queues(struct request_queue *q,
22632269 * Set local node, IFF we have more than one hw queue. If
22642270 * not, we remain on the home node of the device
22652271 */
2266- hctx = blk_mq_map_queue ( q , i );
2272+ hctx = blk_mq_map_queue_type ( q , 0 , i );
22672273 if (nr_hw_queues > 1 && hctx -> numa_node == NUMA_NO_NODE )
22682274 hctx -> numa_node = local_memory_node (cpu_to_node (i ));
22692275 }
@@ -2336,7 +2342,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)
23362342 }
23372343
23382344 ctx = per_cpu_ptr (q -> queue_ctx , i );
2339- hctx = blk_mq_map_queue ( q , i );
2345+ hctx = blk_mq_map_queue_type ( q , 0 , i );
23402346
23412347 cpumask_set_cpu (i , hctx -> cpumask );
23422348 ctx -> index_hw = hctx -> nr_ctx ;
0 commit comments