Skip to content

Commit 6b7b181

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: remove the bd_block_size field from struct block_device
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. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 5ff9f19 commit 6b7b181

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

fs/block_dev.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ EXPORT_SYMBOL(invalidate_bdev);
105105

106106
static void set_init_blocksize(struct block_device *bdev)
107107
{
108-
unsigned bsize = bdev_logical_block_size(bdev);
109-
110-
bdev->bd_block_size = bsize;
111-
bdev->bd_inode->i_blkbits = blksize_bits(bsize);
108+
bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev));
112109
}
113110

114111
int set_blocksize(struct block_device *bdev, int size)
@@ -122,9 +119,8 @@ int set_blocksize(struct block_device *bdev, int size)
122119
return -EINVAL;
123120

124121
/* Don't change the size if it is same as current */
125-
if (bdev->bd_block_size != size) {
122+
if (bdev->bd_inode->i_blkbits != blksize_bits(size)) {
126123
sync_blockdev(bdev);
127-
bdev->bd_block_size = size;
128124
bdev->bd_inode->i_blkbits = blksize_bits(size);
129125
kill_bdev(bdev);
130126
}
@@ -889,7 +885,6 @@ struct block_device *bdget(dev_t dev)
889885
bdev->bd_contains = NULL;
890886
bdev->bd_super = NULL;
891887
bdev->bd_inode = inode;
892-
bdev->bd_block_size = i_blocksize(inode);
893888
bdev->bd_part_count = 0;
894889
bdev->bd_invalidated = 0;
895890
inode->i_mode = S_IFBLK;

include/linux/blk_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ struct block_device {
3333
struct list_head bd_holder_disks;
3434
#endif
3535
struct block_device * bd_contains;
36-
unsigned bd_block_size;
3736
u8 bd_partno;
3837
struct hd_struct * bd_part;
3938
/* number of times partitions within this device have been opened. */

include/linux/blkdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ static inline unsigned int blksize_bits(unsigned int size)
15431543

15441544
static inline unsigned int block_size(struct block_device *bdev)
15451545
{
1546-
return bdev->bd_block_size;
1546+
return 1 << bdev->bd_inode->i_blkbits;
15471547
}
15481548

15491549
int kblockd_schedule_work(struct work_struct *work);

0 commit comments

Comments
 (0)