[PATCH 36/44] block: allocate struct hd_struct as part of struct bdev_inode

Jan Kara jack at suse.cz
Thu Nov 26 12:35:18 EST 2020


On Thu 26-11-20 14:04:14, Christoph Hellwig wrote:
> Allocate hd_struct together with struct block_device to pre-load
> the lifetime rule changes in preparation of merging the two structures.
> 
> Note that part0 was previously embedded into struct gendisk, but is
> a separate allocation now, and already points to the block_device instead
> of the hd_struct.  The lifetime of struct gendisk is still controlled by
> the struct device embedded in the part0 hd_struct.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>

Just one comment below. With that fixed feel free to add:

Reviewed-by: Jan Kara <jack at suse.cz>

> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index f397ec9922bd6e..9c7e6730fa6098 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -265,9 +265,9 @@ static const struct attribute_group *part_attr_groups[] = {
>  static void part_release(struct device *dev)
>  {
>  	struct hd_struct *p = dev_to_part(dev);
> +
>  	blk_free_devt(dev->devt);
> -	hd_free_part(p);
> -	kfree(p);
> +	bdput(p->bdev);
>  }

I don't think hd_struct holds a reference to block_device, does it?
bdev_alloc() now just assigns bdev->bd_part->bdev = bdev...

								Honza
-- 
Jan Kara <jack at suse.com>
SUSE Labs, CR



More information about the linux-mtd mailing list