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

Keith Busch
2019-03-27T00:03:51Z

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);

We actually still have to unquieces the queue to flush entered requests to
a failed completion after killing that queue, like in nvme_set_queue_dying().