Re: [PATCH 03/32] block: Use blkdev_get_handle_by_dev() in blkdev_open()

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

 



On Wed 05-07-23 10:35:10, Kanchan Joshi wrote:
> On Tue, Jul 04, 2023 at 02:21:30PM +0200, Jan Kara wrote:
> > Convert blkdev_open() to use blkdev_get_handle_by_dev().
> > 
> > Signed-off-by: Jan Kara <jack@xxxxxxx>
> > ---
> > block/fops.c | 17 +++++++++--------
> > 1 file changed, 9 insertions(+), 8 deletions(-)
> > 
> > diff --git a/block/fops.c b/block/fops.c
> > index b6aa470c09ae..d7f3b6e67a2f 100644
> > --- a/block/fops.c
> > +++ b/block/fops.c
> > @@ -496,7 +496,7 @@ blk_mode_t file_to_blk_mode(struct file *file)
> > 
> > static int blkdev_open(struct inode *inode, struct file *filp)
> > {
> > -	struct block_device *bdev;
> > +	struct bdev_handle *handle;
> > 	blk_mode_t mode;
> > 
> > 	/*
> > @@ -509,24 +509,25 @@ static int blkdev_open(struct inode *inode, struct file *filp)
> > 	filp->f_mode |= FMODE_BUF_RASYNC;
> > 
> > 	mode = file_to_blk_mode(filp);
> > -	bdev = blkdev_get_by_dev(inode->i_rdev, mode,
> > -				 mode & BLK_OPEN_EXCL ? filp : NULL, NULL);
> > -	if (IS_ERR(bdev))
> > -		return PTR_ERR(bdev);
> > +	handle = blkdev_get_handle_by_dev(inode->i_rdev, mode,
> > +			mode & BLK_OPEN_EXCL ? filp : NULL, NULL);
> > +	if (IS_ERR(handle))
> > +		return PTR_ERR(handle);
> > 
> > 	if (mode & BLK_OPEN_EXCL)
> > 		filp->private_data = filp;
> 
> Is this needed?
> This is getting overwritten after a couple of lines below.
> 
> > -	if (bdev_nowait(bdev))
> > +	if (bdev_nowait(handle->bdev))
> > 		filp->f_mode |= FMODE_NOWAIT;
> > 
> > -	filp->f_mapping = bdev->bd_inode->i_mapping;
> > +	filp->f_mapping = handle->bdev->bd_inode->i_mapping;
> > 	filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
> > +	filp->private_data = handle;
> 
> Here.

Good point, I'll fix that for the next version. Thanks for review!

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[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