Message ID | 20240222124555.2049140-2-yukuai1@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fs & block: remove bdev->bd_inode | expand |
On Thu 22-02-24 20:45:37, Yu Kuai wrote: > From: Yu Kuai <yukuai3@huawei.com> > > disk_live() and block_size() access bd_inode directly, prepare to remove > the field bd_inode from block_device, and only access bd_inode in block > layer. > > Signed-off-by: Yu Kuai <yukuai3@huawei.com> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > block/bdev.c | 12 ++++++++++++ > include/linux/blkdev.h | 12 ++---------- > 2 files changed, 14 insertions(+), 10 deletions(-) > > diff --git a/block/bdev.c b/block/bdev.c > index 140093c99bdc..726a2805a1ce 100644 > --- a/block/bdev.c > +++ b/block/bdev.c > @@ -1196,6 +1196,18 @@ void bdev_statx_dioalign(struct inode *inode, struct kstat *stat) > blkdev_put_no_open(bdev); > } > > +bool disk_live(struct gendisk *disk) > +{ > + return !inode_unhashed(disk->part0->bd_inode); > +} > +EXPORT_SYMBOL_GPL(disk_live); > + > +unsigned int block_size(struct block_device *bdev) > +{ > + return 1 << bdev->bd_inode->i_blkbits; > +} > +EXPORT_SYMBOL_GPL(block_size); > + > static int __init setup_bdev_allow_write_mounted(char *str) > { > if (kstrtobool(str, &bdev_allow_write_mounted)) > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 06e854186947..eb1f6eeaddc5 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -211,11 +211,6 @@ struct gendisk { > struct blk_independent_access_ranges *ia_ranges; > }; > > -static inline bool disk_live(struct gendisk *disk) > -{ > - return !inode_unhashed(disk->part0->bd_inode); > -} > - > /** > * disk_openers - returns how many openers are there for a disk > * @disk: disk to check > @@ -1359,11 +1354,6 @@ static inline unsigned int blksize_bits(unsigned int size) > return order_base_2(size >> SECTOR_SHIFT) + SECTOR_SHIFT; > } > > -static inline unsigned int block_size(struct block_device *bdev) > -{ > - return 1 << bdev->bd_inode->i_blkbits; > -} > - > int kblockd_schedule_work(struct work_struct *work); > int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); > > @@ -1531,6 +1521,8 @@ void blkdev_put_no_open(struct block_device *bdev); > > struct block_device *I_BDEV(struct inode *inode); > struct block_device *file_bdev(struct file *bdev_file); > +bool disk_live(struct gendisk *disk); > +unsigned int block_size(struct block_device *bdev); > > #ifdef CONFIG_BLOCK > void invalidate_bdev(struct block_device *bdev); > -- > 2.39.2 >
On Thu, Feb 22, 2024 at 08:45:37PM +0800, Yu Kuai wrote: > From: Yu Kuai <yukuai3@huawei.com> > > disk_live() and block_size() access bd_inode directly, prepare to remove > the field bd_inode from block_device, and only access bd_inode in block > layer. This looks good in general. Reviewed-by: Christoph Hellwig <hch@lst.de> (I wish we could eventually retired block_size() and the whole concept of soft "block size" that could be different form the LBA size, but that's a totally different adventure)
diff --git a/block/bdev.c b/block/bdev.c index 140093c99bdc..726a2805a1ce 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -1196,6 +1196,18 @@ void bdev_statx_dioalign(struct inode *inode, struct kstat *stat) blkdev_put_no_open(bdev); } +bool disk_live(struct gendisk *disk) +{ + return !inode_unhashed(disk->part0->bd_inode); +} +EXPORT_SYMBOL_GPL(disk_live); + +unsigned int block_size(struct block_device *bdev) +{ + return 1 << bdev->bd_inode->i_blkbits; +} +EXPORT_SYMBOL_GPL(block_size); + static int __init setup_bdev_allow_write_mounted(char *str) { if (kstrtobool(str, &bdev_allow_write_mounted)) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 06e854186947..eb1f6eeaddc5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -211,11 +211,6 @@ struct gendisk { struct blk_independent_access_ranges *ia_ranges; }; -static inline bool disk_live(struct gendisk *disk) -{ - return !inode_unhashed(disk->part0->bd_inode); -} - /** * disk_openers - returns how many openers are there for a disk * @disk: disk to check @@ -1359,11 +1354,6 @@ static inline unsigned int blksize_bits(unsigned int size) return order_base_2(size >> SECTOR_SHIFT) + SECTOR_SHIFT; } -static inline unsigned int block_size(struct block_device *bdev) -{ - return 1 << bdev->bd_inode->i_blkbits; -} - int kblockd_schedule_work(struct work_struct *work); int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); @@ -1531,6 +1521,8 @@ void blkdev_put_no_open(struct block_device *bdev); struct block_device *I_BDEV(struct inode *inode); struct block_device *file_bdev(struct file *bdev_file); +bool disk_live(struct gendisk *disk); +unsigned int block_size(struct block_device *bdev); #ifdef CONFIG_BLOCK void invalidate_bdev(struct block_device *bdev);