[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 01/32] block: Provide blkdev_get_handle_* functions
- To: Keith Busch <kbusch@xxxxxxxxxx>
- From: Jan Kara <jack@xxxxxxx>
- Date: Wed, 5 Jul 2023 12:21:28 +0200
- Cc: Jan Kara <jack@xxxxxxx>, linux-block@xxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, Jens Axboe <axboe@xxxxxxxxx>, Christoph Hellwig <hch@xxxxxxxxxxxxx>, Alasdair Kergon <agk@xxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Anna Schumaker <anna@xxxxxxxxxx>, Chao Yu <chao@xxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, "Darrick J. Wong" <djwong@xxxxxxxxxx>, Dave Kleikamp <shaggy@xxxxxxxxxx>, David Sterba <dsterba@xxxxxxxx>, dm-devel@xxxxxxxxxx, drbd-dev@xxxxxxxxxxxxxxxx, Gao Xiang <xiang@xxxxxxxxxx>, Jack Wang <jinpu.wang@xxxxxxxxx>, Jaegeuk Kim <jaegeuk@xxxxxxxxxx>, jfs-discussion@xxxxxxxxxxxxxxxxxxxxx, Joern Engel <joern@xxxxxxxxxxxxxxx>, Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>, Kent Overstreet <kent.overstreet@xxxxxxxxx>, linux-bcache@xxxxxxxxxxxxxxx, linux-btrfs@xxxxxxxxxxxxxxx, linux-erofs@xxxxxxxxxxxxxxxx, linux-ext4@xxxxxxxxxxxxxxx, linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, linux-nfs@xxxxxxxxxxxxxxx, linux-nilfs@xxxxxxxxxxxxxxx, linux-nvme@xxxxxxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, linux-raid@xxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-scsi@xxxxxxxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx, "Md. Haris Iqbal" <haris.iqbal@xxxxxxxxx>, Mike Snitzer <snitzer@xxxxxxxxxx>, Minchan Kim <minchan@xxxxxxxxxx>, ocfs2-devel@xxxxxxxxxxxxxx, reiserfs-devel@xxxxxxxxxxxxxxx, Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>, Song Liu <song@xxxxxxxxxx>, Sven Schnelle <svens@xxxxxxxxxxxxx>, target-devel@xxxxxxxxxxxxxxx, Ted Tso <tytso@xxxxxxx>, Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Wed, 05 Jul 2023 10:21:32 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue 04-07-23 10:28:36, Keith Busch wrote:
> 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);
>
> I believe 'sizeof(*handle)' is the preferred style.
OK.
> > + 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);
>
> Need a 'kfree(handle)' before the error return. Or would it be simpler
> to get the bdev first so you can check the mode settings against a
> read-only bdev prior to the kmalloc?
Yeah. Good point with kfree(). I'm not sure calling blkdev_get_by_dev()
first will be "simpler" - then we need blkdev_put() in case of kmalloc()
failure. Thanks for review!
Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR
|