public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>, axboe@kernel.dk
Cc: linux-block@vger.kernel.org, Daniel Wagner <dwagner@suse.de>
Subject: Re: [PATCH] block: fix leaking minors of hidden disks
Date: Wed, 12 Oct 2022 08:20:54 +0200	[thread overview]
Message-ID: <0d869239-73bb-b61a-6a33-2219f3d635ef@suse.de> (raw)
In-Reply-To: <20221010131857.748129-1-hch@lst.de>

On 10/10/22 15:18, Christoph Hellwig wrote:
> 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.
> 
> Fixes:  8ddcd653257c ("block: introduce GENHD_FL_HIDDEN")
> Reported-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Tested-by: Daniel Wagner <dwagner@suse.de>
> ---
>   block/genhd.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 514395361d7c5..17b33c62423df 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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);

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +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


  parent reply	other threads:[~2022-10-12  6:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 13:18 [PATCH] block: fix leaking minors of hidden disks Christoph Hellwig
2022-10-10 13:34 ` Keith Busch
2022-10-10 14:49 ` Jens Axboe
2022-10-12  6:20 ` Hannes Reinecke [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-07 19:32 Keith Busch
2022-10-07 19:36 ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d869239-73bb-b61a-6a33-2219f3d635ef@suse.de \
    --to=hare@suse.de \
    --cc=axboe@kernel.dk \
    --cc=dwagner@suse.de \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox