[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 13/20] block: remove ->bd_contains



On Wed 18-11-20 09:47:53, Christoph Hellwig wrote:
> Now that each hd_struct has a reference to the corresponding
> block_device, there is no need for the bd_contains pointer.  Add
> a bdev_whole() helper to look up the whole device block_device
> struture instead.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Just two nits below. Otherwise feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

> @@ -1521,7 +1510,7 @@ static int __blkdev_get(struct block_device *bdev, 
> fmode_t mode, void *holder,
>               if (bdev->bd_bdi == &noop_backing_dev_info)
>                       bdev->bd_bdi = bdi_get(disk->queue->backing_dev_info);
>       } else {
> -             if (bdev->bd_contains == bdev) {
> +             if (!bdev->bd_partno) {

This should be !bdev_is_partition(bdev) for consistency, right?

>                       ret = 0;
>                       if (bdev->bd_disk->fops->open)
>                               ret = bdev->bd_disk->fops->open(bdev, mode);
...
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 0069bee992063e..453b940b87d8e9 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -32,7 +32,6 @@ struct block_device {
>  #ifdef CONFIG_SYSFS
>       struct list_head        bd_holder_disks;
>  #endif
> -     struct block_device *   bd_contains;
>       u8                      bd_partno;
>       struct hd_struct *      bd_part;
>       /* number of times partitions within this device have been opened. */
> @@ -48,6 +47,9 @@ struct block_device {
>       struct mutex            bd_fsfreeze_mutex;
>  } __randomize_layout;
>  
> +#define bdev_whole(_bdev) \
> +     ((_bdev)->bd_disk->part0.bdev)
> +
>  #define bdev_kobj(_bdev) \
>       (&part_to_dev((_bdev)->bd_part)->kobj)

I'd somewhat prefer if these helpers could actually be inline functions and
not macros. I guess they are macros because hd_struct isn't in blk_types.h.
But if we moved helpers to blkdev.h, we'd have all definitions we need...
Is that a problem for some users?

                                                                Honza

-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.