linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] block: call blk_mq_exit_queue from disk_release for never added disks
@ 2022-07-18  6:29 Christoph Hellwig
  2022-07-18  6:29 ` [PATCH 2/2] Revert "ublk_drv: fix request queue leak" Christoph Hellwig
  2022-07-18  7:18 ` [PATCH 1/2] block: call blk_mq_exit_queue from disk_release for never added disks Ming Lei
  0 siblings, 2 replies; 16+ messages in thread
From: Christoph Hellwig @ 2022-07-18  6:29 UTC (permalink / raw)
  To: axboe; +Cc: ming.lei, linux-block

To undo the all initialization from blk_mq_init_allocated_queue in case
of a probe failure where add_disk is never called we have to call
blk_mq_exit_queue from put_disk.

We should be doing this in general, but can't do it for the normal
teardown case (yet) as the tagset can be gone by the time the disk is
released once it was added.  I hope to sort this out properly eventual
but for now this isolated hack will do it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/block/genhd.c b/block/genhd.c
index 44dfcf67ed96a..ad8a3678d4480 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1138,6 +1138,18 @@ static void disk_release(struct device *dev)
 	might_sleep();
 	WARN_ON_ONCE(disk_live(disk));
 
+	/*
+	 * To undo the all initialization from blk_mq_init_allocated_queue in
+	 * case of a probe failure where add_disk is never called we have to
+	 * call blk_mq_exit_queue here. We can't do this for the more common
+	 * teardown case (yet) as the tagset can be gone by the time the disk
+	 * is released once it was added.
+	 */
+	if (queue_is_mq(disk->queue) &&
+	    test_bit(GD_OWNS_QUEUE, &disk->state) &&
+	    !test_bit(GD_ADDED, &disk->state))
+		blk_mq_exit_queue(disk->queue);
+
 	blkcg_exit_queue(disk->queue);
 
 	disk_release_events(disk);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-07-21  5:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18  6:29 [PATCH 1/2] block: call blk_mq_exit_queue from disk_release for never added disks Christoph Hellwig
2022-07-18  6:29 ` [PATCH 2/2] Revert "ublk_drv: fix request queue leak" Christoph Hellwig
2022-07-19 12:37   ` Ming Lei
2022-07-20  6:07     ` Christoph Hellwig
2022-07-20  7:47       ` Ming Lei
2022-07-20  9:00         ` Christoph Hellwig
2022-07-20 10:16           ` Ming Lei
2022-07-20 10:23           ` Ming Lei
2022-07-20 13:08             ` Christoph Hellwig
2022-07-20 15:33               ` Ming Lei
2022-07-21  5:12                 ` Christoph Hellwig
2022-07-18  7:18 ` [PATCH 1/2] block: call blk_mq_exit_queue from disk_release for never added disks Ming Lei
2022-07-18  8:33   ` Ming Lei
2022-07-18 13:08     ` Christoph Hellwig
2022-07-18 13:07   ` Christoph Hellwig
2022-07-18 15:16     ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).