On Mon, Jul 18, 2022 at 08:29:27AM +0200, Christoph Hellwig wrote: > 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@xxxxxx> > --- > 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); > + Request queue is allocated successfully, but disk allocation may fail, so blk_mq_exit_queue still may be missed in this case. thanks, Ming