Re: [PATCH 66/78] block: keep a block_device reference for each hd_struct

Hannes Reinecke
2020-11-20T07:50:39Z

On 11/16/20 3:57 PM, Christoph Hellwig wrote:
> To simplify block device lookup and a few other upcomdin areas, make sure
> that we always have a struct block_device available for each disk and
> each partition. The only downside of this is that each device and
> partition uses a little more memories. The upside will be that a lot of
> code can be simplified.
>
> With that all we need to look up the block device is to lookup the inode
> and do a few sanity checks on the gendisk, instead of the separate lookup
> for the gendisk.
>
> As part of the change switch bdget() to only find existing block devices,
> given that we know that the block_device structure must be allocated at
> probe / partition scan time.
>
> blk-cgroup needed a bit of a special treatment as the only place that
> wanted to lookup a gendisk outside of the normal blkdev_get path. It is
> switched to lookup using the block device hash now that this is the
> primary lookup path.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-cgroup.c | 42 ++++-----
> block/blk-iocost.c | 36 +++----
> block/blk.h | 1 -
> block/genhd.c | 188 +++----------------------------------
> block/partitions/core.c | 28 +++---
> fs/block_dev.c | 133 +++++++++++++++-----------
> include/linux/blk-cgroup.h | 4 +-
> include/linux/blkdev.h | 3 +
> include/linux/genhd.h | 4 +-
> 9 files changed, 153 insertions(+), 286 deletions(-)
>
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: Felix Imendörffer