Re: [PATCH] block: don't call blk_mq_run_hw_queues() for dead or dying queues

Bart Van Assche
2019-03-26T13:43:32Z

On 3/26/19 5:07 AM, Hannes Reinecke wrote:
> When a queue is dying or dead there is no point in calling
> blk_mq_run_hw_queues() in blk_mq_unquiesce_queue(); in fact, doing
> so might crash the machine as the queue structures are in the
> process of being deleted.
>
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
> block/blk-mq.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a9c181603cbd..b1eeba38bc79 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -258,7 +258,8 @@ void blk_mq_unquiesce_queue(struct request_queue *q)
> blk_queue_flag_clear(QUEUE_FLAG_QUIESCED, q);
>
> /* dispatch requests which are inserted during quiescing */
> - blk_mq_run_hw_queues(q, true);
> + if (!blk_queue_dying(q) && !blk_queue_dead(q))
> + blk_mq_run_hw_queues(q, true);
> }
> EXPORT_SYMBOL_GPL(blk_mq_unquiesce_queue);

Hi Hannes,

Please provide more context information. In the "dead" state the queue
must be run to make sure that all requests that were queued before the
"dead" state get processed. The blk_cleanup_queue() function is
responsible for stopping all code that can run the queue after all
requests have finished and before destruction of the data structures
needed for request processing starts.

Bart.