block: fix leaking minors of hidden disks
PATCH 1/1 block: fix leaking minors of hidden disks
The major/minor of a hidden gendisk is not propagated to the block device because it is never registered using bdev_add. But the lack of bd_dev also causes the dynamic major minor number not to be freed. Assign bd_dev manually to ensure the dynamic major minor gets freed.
Based on a patch by Keith Busch.
--- block/genhd.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/genhd.c +7 -0
@@ -507,6 +507,13 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,*/ dev_set_uevent_suppress (ddev,0 );disk_uevent (disk,KOBJ_ADD ); + }else { +/* +* Even if the block_device for a hidden gendisk is not +* registered, it needs to have a valid bd_dev so that the +* freeing of the dynamic major works. +*/ + disk->part0->bd_dev =MKDEV (disk->major, disk->first_minor); }disk_update_readahead (disk);
Signature · 1 line
2.30.2
Quoted 5 lines · Christoph Hellwig
The major/minor of a hidden gendisk is not propagated to the block device because it is never registered using
bdev_add. But the lack ofbd_devalso causes the dynamic major minor number not to be freed. Assignbd_devmanually to ensure the dynamic major minor gets freed.
Looks good.
Quoted 8 lines · Christoph Hellwig
The major/minor of a hidden gendisk is not propagated to the block device because it is never registered using
bdev_add. But the lack ofbd_devalso causes the dynamic major minor number not to be freed. Assignbd_devmanually to ensure the dynamic major minor gets freed.Based on a patch by Keith Busch.
[...]
Applied, thanks!
[1/1] block: fix leaking minors of hidden disks
commit: a0a6314ae774f8a5e52a599946aa2ad0db867b83
Best regards,
Signature · 1 line
Jens Axboe
Quoted 23 lines · Christoph Hellwig
The major/minor of a hidden gendisk is not propagated to the block device because it is never registered using
bdev_add. But the lack ofbd_devalso causes the dynamic major minor number not to be freed. Assignbd_devmanually to ensure the dynamic major minor gets freed.Based on a patch by Keith Busch.
Fixes 8ddcd653257c ("block: introduce GENHD_FL_HIDDEN")Reported-by Daniel Wagner <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Daniel Wagner <[email protected]>--- block/genhd.c | 7 +++++++ 1 file changed, 7 insertions(+)block/genhd.c +0
-0@@ -507,6 +507,13 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,*/ dev_set_uevent_suppress (ddev,0 );disk_uevent (disk,KOBJ_ADD );
block/genhd.c int __must_check device_add_disk(struct device *parent, struct gendisk *disk, · line 519
Quoted 10 lines
block/genhd.c +7
-0+ }else { +/* +* Even if the block_device for a hidden gendisk is not +* registered, it needs to have a valid bd_dev so that the +* freeing of the dynamic major works. +*/ + disk->part0->bd_dev =MKDEV (disk->major, disk->first_minor); }disk_update_readahead (disk);
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman