All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: ensure the extended dev_t gets free for hidden gendisks
@ 2021-12-22  9:31 Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2021-12-22  9:31 UTC (permalink / raw)
  To: axboe; +Cc: linux-block

Manually set bd_bdev for hidden gendisk to ensure they are freed when the
whole device bdev inode is freed.  For normal gendisks this is done by
bdev_add, which isn't called for hidden ones.

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

diff --git a/block/genhd.c b/block/genhd.c
index 626c8406f21a6..563fb84ff746f 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -498,7 +498,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
 	if (ret)
 		goto out_put_slave_dir;
 
-	if (!(disk->flags & GENHD_FL_HIDDEN)) {
+	if (disk->flags & GENHD_FL_HIDDEN) {
+		/* needed so that the extended dev_t gets freed */
+		disk->part0->bd_dev = MKDEV(disk->major, disk->first_minor);
+	} else {
 		ret = bdi_register(disk->bdi, "%u:%u",
 				   disk->major, disk->first_minor);
 		if (ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-22  9:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22  9:31 [PATCH] block: ensure the extended dev_t gets free for hidden gendisks Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.