diff mbox series

[4/7] block: remove the bd_block_size field from struct block_device

Message ID 20200626080158.1998621-5-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/7] floppy: use block_size | expand

Commit Message

Christoph Hellwig June 26, 2020, 8:01 a.m. UTC
We can trivially calculate the block size from the inodes i_blkbits
variable.  Use that instead of keeping two redundant copies of the
information in slightly different formats.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c            | 9 ++-------
 include/linux/blk_types.h | 1 -
 include/linux/blkdev.h    | 2 +-
 3 files changed, 3 insertions(+), 9 deletions(-)

Comments

Johannes Thumshirn July 1, 2020, 7:29 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 8b7a9c76d33edf..06d31e459048ad 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -105,10 +105,7 @@  EXPORT_SYMBOL(invalidate_bdev);
 
 static void set_init_blocksize(struct block_device *bdev)
 {
-	unsigned bsize = bdev_logical_block_size(bdev);
-
-	bdev->bd_block_size = bsize;
-	bdev->bd_inode->i_blkbits = blksize_bits(bsize);
+	bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev));
 }
 
 int set_blocksize(struct block_device *bdev, int size)
@@ -122,9 +119,8 @@  int set_blocksize(struct block_device *bdev, int size)
 		return -EINVAL;
 
 	/* Don't change the size if it is same as current */
-	if (bdev->bd_block_size != size) {
+	if (bdev->bd_inode->i_blkbits != blksize_bits(size)) {
 		sync_blockdev(bdev);
-		bdev->bd_block_size = size;
 		bdev->bd_inode->i_blkbits = blksize_bits(size);
 		kill_bdev(bdev);
 	}
@@ -889,7 +885,6 @@  struct block_device *bdget(dev_t dev)
 		bdev->bd_contains = NULL;
 		bdev->bd_super = NULL;
 		bdev->bd_inode = inode;
-		bdev->bd_block_size = i_blocksize(inode);
 		bdev->bd_part_count = 0;
 		bdev->bd_invalidated = 0;
 		inode->i_mode = S_IFBLK;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index a602132cbe32c2..b01cd19bbe8a6e 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -33,7 +33,6 @@  struct block_device {
 	struct list_head	bd_holder_disks;
 #endif
 	struct block_device *	bd_contains;
-	unsigned		bd_block_size;
 	u8			bd_partno;
 	struct hd_struct *	bd_part;
 	/* number of times partitions within this device have been opened. */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 15497782c17656..752a4b771e2f2f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1548,7 +1548,7 @@  static inline unsigned int blksize_bits(unsigned int size)
 
 static inline unsigned int block_size(struct block_device *bdev)
 {
-	return bdev->bd_block_size;
+	return 1 << bdev->bd_inode->i_blkbits;
 }
 
 int kblockd_schedule_work(struct work_struct *work);