On Wed, Apr 24, 2019 at 07:02:13PM +0800, Ming Lei wrote:
>               if (rq->mq_hctx != this_hctx || rq->mq_ctx != this_ctx) {
>                       if (this_hctx) {
>                               trace_block_unplug(this_q, depth, 
> !from_schedule);
> +
> +                             percpu_ref_get(&this_q->q_usage_counter);
>                               blk_mq_sched_insert_requests(this_hctx, 
> this_ctx,
>                                                               &rq_list,
>                                                               from_schedule);
> +                             percpu_ref_put(&this_q->q_usage_counter);
>                       }
>  
>                       this_q = rq->q;
> @@ -1757,8 +1760,11 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, 
> bool from_schedule)
>        */
>       if (this_hctx) {
>               trace_block_unplug(this_q, depth, !from_schedule);
> +
> +             percpu_ref_get(&this_q->q_usage_counter);
>               blk_mq_sched_insert_requests(this_hctx, this_ctx, &rq_list,
>                                               from_schedule);
> +             percpu_ref_put(&this_q->q_usage_counter);

Why don't we push this into blk_mq_sched_insert_requests?  Yes, it
would need a request_queue argument, but that still seems saner
than duplicating it in both callers.

Reply via email to