diff --git a/block/blk-core.c b/block/blk-core.c index 78a4f91abf9c55c29cab78d3c09b4871a2b83445..dcf1ab09e10ef76d7b74a1288a07b57f0ed79ac4 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -784,6 +784,18 @@ void blk_cleanup_queue(struct request_queue *q) queue_flag_set(QUEUE_FLAG_DEAD, q); spin_unlock_irq(lock); + /* + * make sure all in-progress dispatch are completed because + * blk_freeze_queue() can only complete all requests, and + * dispatch may still be in-progress since we dispatch requests + * from more than one contexts. + * + * We rely on driver to deal with the race in case that queue + * initialization isn't done. + */ + if (q->mq_ops && blk_queue_init_done(q)) + blk_mq_quiesce_queue(q); + /* for synchronous bio-based driver finish in-flight integrity i/o */ blk_flush_integrity();