Skip to content

Commit bcc6e2c

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: add a sb_bdev_nr_blocks helper
Add a helper to return the size of sb->s_bdev in sb->s_blocksize_bits based unites. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 2a93ad8 commit bcc6e2c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/linux/genhd.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ static inline sector_t get_capacity(struct gendisk *disk)
251251
return bdev_nr_sectors(disk->part0);
252252
}
253253

254+
static inline u64 sb_bdev_nr_blocks(struct super_block *sb)
255+
{
256+
return bdev_nr_sectors(sb->s_bdev) >>
257+
(sb->s_blocksize_bits - SECTOR_SHIFT);
258+
}
259+
254260
int bdev_disk_changed(struct gendisk *disk, bool invalidate);
255261
void blk_drop_partitions(struct gendisk *disk);
256262

0 commit comments

Comments
 (0)