summaryrefslogtreecommitdiff
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-10-18 12:11:25 +0200
committerJens Axboe <axboe@kernel.dk>2021-10-18 14:43:23 -0600
commitbcc6e2cfaa48a4ad2e17719194f6d97a8e03f6c1 (patch)
tree9a36696de024646f0d341b904d56b94ec1c2cd8b /include/linux/genhd.h
parent2a93ad8fcb377b9d6e05947de161e146f5be4de9 (diff)
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 <hch@lst.de> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20211018101130.1838532-26-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r--include/linux/genhd.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 01d27f3a970e..7b0326661a1e 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -251,6 +251,12 @@ static inline sector_t get_capacity(struct gendisk *disk)
return bdev_nr_sectors(disk->part0);
}
+static inline u64 sb_bdev_nr_blocks(struct super_block *sb)
+{
+ return bdev_nr_sectors(sb->s_bdev) >>
+ (sb->s_blocksize_bits - SECTOR_SHIFT);
+}
+
int bdev_disk_changed(struct gendisk *disk, bool invalidate);
void blk_drop_partitions(struct gendisk *disk);