From ffe4511d8939ce089b85b1a76442a2409929bd4f Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Thu, 11 Feb 2016 13:05:38 -0700 Subject: [PATCH 3/3] blk-mq: End unstarted requests on dying queue Go directly to ending a request if it wasn't started. Previously, completing a request may invoke a driver callback for a request it didn't initialize. Signed-off-by: Keith Busch Reviewed-by: Sagi Grimberg Reviewed-by: Johannes Thumshirn Acked-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Gabriel Krisman Bertazi [Backport to Ubuntu kernel.] --- block/blk-mq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 93a4e19..d49784a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -599,8 +599,10 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx, * If a request wasn't started before the queue was * marked dying, kill it here or it'll go unnoticed. */ - if (unlikely(blk_queue_dying(rq->q))) + if (unlikely(blk_queue_dying(rq->q))) { + rq->errors = -EIO; blk_mq_complete_request(rq, -EIO); + } return; } if (rq->cmd_flags & REQ_NO_TIMEOUT) -- 2.1.0