Re: [RFC PATCH 01/18] block: add and use init disk helper
- To: Chaitanya Kulkarni <kch@nvidia.com>
- Cc: ogeert@linux-m68k.org, linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, drbd-dev@lists.linbit.com, nbd@other.debian.org, linux-mtd@lists.infradead.org, axboe@kernel.dk, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, christoph.boehmwalder@linbit.com, efremov@linux.com, josef@toxicpanda.com, tim@cyberelk.net, haris.iqbal@ionos.com, jinpu.wang@ionos.com, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, mcgrof@kernel.org, hare@suse.de, damien.lemoal@opensource.wdc.com, johannes.thumshirn@wdc.com, bvanassche@acm.org, ming.lei@redhat.com, vincent.fu@samsung.com, shinichiro.kawasaki@wdc.com
- Subject: Re: [RFC PATCH 01/18] block: add and use init disk helper
- From: Christoph Hellwig <hch@infradead.org>
- Date: Mon, 10 Oct 2022 00:59:01 -0700
- Message-id: <[🔎] Y0PQxdzmMzAAW0KF@infradead.org>
- In-reply-to: <20221005050027.39591-2-kch@nvidia.com>
- References: <20221005050027.39591-1-kch@nvidia.com> <20221005050027.39591-2-kch@nvidia.com>
On Tue, Oct 04, 2022 at 10:00:10PM -0700, Chaitanya Kulkarni wrote:
> +void init_disk(struct gendisk *disk, int major, int first_minor,
> + int minors, sector_t sectors, void *private_data,
> + const struct block_device_operations *fops)
> +{
> + disk->major = major;
> + disk->first_minor = first_minor;
> + disk->minors = minors;
> + set_capacity(disk, sectors);
> + disk->private_data = private_data;
> + disk->fops = fops;
I don't like this at all. For one major/first_minor/minors are
optional and discouraged for new drivers. Setting the capacity is
a different thing and is done by helpers also used for revalidation
in many drivers.
It might make sense to pass the fops (and maybe private_data) to
blk_mq_alloc_disk / blk_alloc_disk, but even then I'm not quite
sure it is worth the churn.
Reply to: