Linux block layer
 help / color / mirror / Atom feed
* [PATCHv2] block: fix leaking minors of hidden disks
@ 2022-10-07 19:38 Keith Busch
  2022-10-10  6:43 ` Daniel Wagner
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Keith Busch @ 2022-10-07 19:38 UTC (permalink / raw)
  To: linux-block, axboe; +Cc: Keith Busch, Christoph Hellwig, Daniel Wagner

From: Keith Busch <kbusch@kernel.org>

The major/minor of a hidden gendisk is not propagated to the block
device. This is required to suppress it from being visible. For these
disks, we need to handle freeing the dynamic minor directly when it's
released since bdev_free_inode() won't be able to.

Cc: Christoph Hellwig <hch@lst.de>
Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
v1->v2:

  Actually check that the disk is hidden before assuming the minor needs
  to be freed.

 block/genhd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/genhd.c b/block/genhd.c
index 514395361d7c..0afcdbb7575c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1166,6 +1166,8 @@ static void disk_release(struct device *dev)
 	if (test_bit(GD_ADDED, &disk->state) && disk->fops->free_disk)
 		disk->fops->free_disk(disk);
 
+	if ((disk->flags & GENHD_FL_HIDDEN) && disk->major == BLOCK_EXT_MAJOR)
+		blk_free_ext_minor(disk->first_minor);
 	iput(disk->part0->bd_inode);	/* frees the disk */
 }
 
-- 
2.30.2


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

end of thread, other threads:[~2022-10-10  8:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07 19:38 [PATCHv2] block: fix leaking minors of hidden disks Keith Busch
2022-10-10  6:43 ` Daniel Wagner
2022-10-10  6:51 ` Chaitanya Kulkarni
2022-10-10  7:36 ` Christoph Hellwig
2022-10-10  8:02   ` Daniel Wagner
2022-10-10  8:19     ` Christoph Hellwig
2022-10-10  8:49       ` Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox