This patch re-organizes blk_mq_exit_hw_queues() into two parts, and one part is for exit hw queues really, and another part is for free hw queues. No function change, just prepare for fixing hctx lifetime issue. Cc: James Smart <james.smart@xxxxxxxxxxxx> Cc: Bart Van Assche <bart.vanassche@xxxxxxx> Cc: linux-scsi@xxxxxxxxxxxxxxx, Cc: Martin K . Petersen <martin.petersen@xxxxxxxxxx>, Cc: Christoph Hellwig <hch@xxxxxx>, Cc: James E . J . Bottomley <jejb@xxxxxxxxxxxxxxxxxx>, Cc: jianchao wang <jianchao.w.wang@xxxxxxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- block/blk-mq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 53265ce45238..a264d1967396 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2265,8 +2265,17 @@ static void blk_mq_exit_hw_queues(struct request_queue *q, queue_for_each_hw_ctx(q, hctx, i) { if (i == nr_queue) break; - blk_mq_debugfs_unregister_hctx(hctx); blk_mq_exit_hctx(q, set, hctx, i); + } +} + +static void blk_mq_free_hw_queues(struct request_queue *q) +{ + struct blk_mq_hw_ctx *hctx; + unsigned int i; + + queue_for_each_hw_ctx(q, hctx, i) { + blk_mq_debugfs_unregister_hctx(hctx); blk_mq_free_hctx(q, hctx); } } @@ -2893,6 +2902,7 @@ void blk_mq_free_queue(struct request_queue *q) blk_mq_del_queue_tag_set(q); blk_mq_exit_hw_queues(q, set, set->nr_hw_queues); + blk_mq_free_hw_queues(q); } static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) -- 2.9.5