@@ -300,6 +300,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
300300 /* csd/requeue_work/fifo_time is initialized before use */
301301 rq -> q = data -> q ;
302302 rq -> mq_ctx = data -> ctx ;
303+ rq -> mq_hctx = data -> hctx ;
303304 rq -> rq_flags = rq_flags ;
304305 rq -> cmd_flags = op ;
305306 if (data -> flags & BLK_MQ_REQ_PREEMPT )
@@ -472,10 +473,11 @@ static void __blk_mq_free_request(struct request *rq)
472473{
473474 struct request_queue * q = rq -> q ;
474475 struct blk_mq_ctx * ctx = rq -> mq_ctx ;
475- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue ( q , rq -> cmd_flags , ctx -> cpu ) ;
476+ struct blk_mq_hw_ctx * hctx = rq -> mq_hctx ;
476477 const int sched_tag = rq -> internal_tag ;
477478
478479 blk_pm_mark_last_busy (rq );
480+ rq -> mq_hctx = NULL ;
479481 if (rq -> tag != -1 )
480482 blk_mq_put_tag (hctx , hctx -> tags , ctx , rq -> tag );
481483 if (sched_tag != -1 )
@@ -489,7 +491,7 @@ void blk_mq_free_request(struct request *rq)
489491 struct request_queue * q = rq -> q ;
490492 struct elevator_queue * e = q -> elevator ;
491493 struct blk_mq_ctx * ctx = rq -> mq_ctx ;
492- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue ( q , rq -> cmd_flags , ctx -> cpu ) ;
494+ struct blk_mq_hw_ctx * hctx = rq -> mq_hctx ;
493495
494496 if (rq -> rq_flags & RQF_ELVPRIV ) {
495497 if (e && e -> type -> ops .finish_request )
@@ -983,7 +985,7 @@ bool blk_mq_get_driver_tag(struct request *rq)
983985{
984986 struct blk_mq_alloc_data data = {
985987 .q = rq -> q ,
986- .hctx = blk_mq_map_queue ( rq -> q , rq -> cmd_flags , rq -> mq_ctx -> cpu ) ,
988+ .hctx = rq -> mq_hctx ,
987989 .flags = BLK_MQ_REQ_NOWAIT ,
988990 .cmd_flags = rq -> cmd_flags ,
989991 };
@@ -1149,7 +1151,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
11491151
11501152 rq = list_first_entry (list , struct request , queuelist );
11511153
1152- hctx = blk_mq_map_queue ( rq -> q , rq -> cmd_flags , rq -> mq_ctx -> cpu ) ;
1154+ hctx = rq -> mq_hctx ;
11531155 if (!got_budget && !blk_mq_get_dispatch_budget (hctx ))
11541156 break ;
11551157
@@ -1579,9 +1581,7 @@ void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
15791581 */
15801582void blk_mq_request_bypass_insert (struct request * rq , bool run_queue )
15811583{
1582- struct blk_mq_ctx * ctx = rq -> mq_ctx ;
1583- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (rq -> q , rq -> cmd_flags ,
1584- ctx -> cpu );
1584+ struct blk_mq_hw_ctx * hctx = rq -> mq_hctx ;
15851585
15861586 spin_lock (& hctx -> lock );
15871587 list_add_tail (& rq -> queuelist , & hctx -> dispatch );
@@ -1790,9 +1790,7 @@ blk_status_t blk_mq_request_issue_directly(struct request *rq)
17901790 blk_status_t ret ;
17911791 int srcu_idx ;
17921792 blk_qc_t unused_cookie ;
1793- struct blk_mq_ctx * ctx = rq -> mq_ctx ;
1794- struct blk_mq_hw_ctx * hctx = blk_mq_map_queue (rq -> q , rq -> cmd_flags ,
1795- ctx -> cpu );
1793+ struct blk_mq_hw_ctx * hctx = rq -> mq_hctx ;
17961794
17971795 hctx_lock (hctx , & srcu_idx );
17981796 ret = __blk_mq_try_issue_directly (hctx , rq , & unused_cookie , true);
@@ -1917,9 +1915,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
19171915 blk_mq_put_ctx (data .ctx );
19181916
19191917 if (same_queue_rq ) {
1920- data .hctx = blk_mq_map_queue (q ,
1921- same_queue_rq -> cmd_flags ,
1922- same_queue_rq -> mq_ctx -> cpu );
1918+ data .hctx = same_queue_rq -> mq_hctx ;
19231919 blk_mq_try_issue_directly (data .hctx , same_queue_rq ,
19241920 & cookie );
19251921 }
0 commit comments