提交 6436bd90 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

block: add a bdev_nr_bytes helper

Add a helper to query the size of a block device in bytes.  This
will be used to remove open coded access to ->bd_inode.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20211018101130.1838532-3-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 99457db8
......@@ -236,9 +236,14 @@ static inline sector_t get_start_sect(struct block_device *bdev)
return bdev->bd_start_sect;
}
static inline loff_t bdev_nr_bytes(struct block_device *bdev)
{
return i_size_read(bdev->bd_inode);
}
static inline sector_t bdev_nr_sectors(struct block_device *bdev)
{
return i_size_read(bdev->bd_inode) >> 9;
return bdev_nr_bytes(bdev) >> SECTOR_SHIFT;
}
static inline sector_t get_capacity(struct gendisk *disk)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册