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

Ming Lei
2019-03-27T01:25:50Z

On Tue, Mar 26, 2019 at 01:07:12PM +0100, 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);

Per previous protocol in legacy io path, the LLD should handle requests
when queue is dying.

Also now, the request queue has become frozen before setting DEAD, so
not necessary to add the DEAD check before run queue.

Thanks,
Ming