Re: [PATCH RFC 01/34] bdev: open block device as files

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

 



On Wed, Jan 17, 2024 at 04:31:07PM +0100, Jan Kara wrote:
> On Wed 03-01-24 13:54:59, Christian Brauner wrote:
> > +struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
> > +				   const struct blk_holder_ops *hops)
> > +{
> > +	struct file *file;
> > +	struct bdev_handle *handle;
> > +	unsigned int flags;
> > +
> > +	handle = bdev_open_by_dev(dev, mode, holder, hops);
> > +	if (IS_ERR(handle))
> > +		return ERR_CAST(handle);
> > +
> > +	flags = blk_to_file_flags(mode);
> > +	file = alloc_file_pseudo(handle->bdev->bd_inode, blockdev_mnt, "",
> > +				 flags | O_LARGEFILE, &def_blk_fops);
> > +	if (IS_ERR(file)) {
> > +		bdev_release(handle);
> > +		return file;
> > +	}
> > +	ihold(handle->bdev->bd_inode);
> > +
> > +	file->f_mode |= FMODE_BUF_RASYNC | FMODE_CAN_ODIRECT | FMODE_NOACCOUNT;
> > +	if (bdev_nowait(handle->bdev))
> > +		file->f_mode |= FMODE_NOWAIT;
> > +
> > +	file->f_mapping = handle->bdev->bd_inode->i_mapping;
> > +	file->f_wb_err = filemap_sample_wb_err(file->f_mapping);
> > +	file->private_data = handle;
> > +	return file;
> 
> Maybe I'm dense but when the file is closed where do we drop the
> bdev_handle?

It's just a bit hidden. blkdev_release() wraps bdev_release():
file->f_op->release::blkdev_release()
-> bdev_release()
But in the updated version the handle is removed completely.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux