Re: [PATCH 01/32] block: Provide blkdev_get_handle_* functions

Matthew Wilcox <[email protected]>
Newsgroups gmane.comp.file-systems.btrfs,gmane.linux.block,gmane.linux.file-systems,gmane.linux.kernel.device-mapper.devel,gmane.linux.kernel.drbd.devel,gmane.linux.kernel.bcache.devel,gmane.comp.file-systems.ext4,gmane.linux.file-systems.f2fs,gmane.linux.kernel.mm,gmane.linux.drivers.mtd,gmane.linux.nfs,gmane.comp.file-systems.nilfs.user,gmane.linux.power-management.general,gmane.linux.raid,gmane.linux.scsi,gmane.comp.file-systems.ocfs2.devel,gmane.comp.file-systems.reiserfs.general,gmane.linux.scsi.target.devel,gmane.comp.emulators.xen.devel
Message-ID <[email protected]>
On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
> +		void *holder, const struct blk_holder_ops *hops)
> +{
> +	struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle),
> +					     GFP_KERNEL);
> +	struct block_device *bdev;
> +
> +	if (!handle)
> +		return ERR_PTR(-ENOMEM);
> +	bdev = blkdev_get_by_dev(dev, mode, holder, hops);
> +	if (IS_ERR(bdev))
> +		return ERR_CAST(bdev);

Would we be better off with a handle->error (and a NULL return from this
function means "we couldn't allocate a handle")?  I have no objection
to what you've done here, just wondering if it might end up nicer for
the users.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.