[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211018101130.1838532-26-hch@lst.de>
Date: Mon, 18 Oct 2021 12:11:25 +0200
From: Christoph Hellwig <hch@....de>
To: Jens Axboe <axboe@...nel.dk>
Cc: Coly Li <colyli@...e.de>, Mike Snitzer <snitzer@...hat.com>,
Song Liu <song@...nel.org>, David Sterba <dsterba@...e.com>,
Josef Bacik <josef@...icpanda.com>,
"Theodore Ts'o" <tytso@....edu>,
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
Dave Kleikamp <shaggy@...nel.org>,
Ryusuke Konishi <konishi.ryusuke@...il.com>,
Anton Altaparmakov <anton@...era.com>,
Konstantin Komarov <almaz.alexandrovich@...agon-software.com>,
Kees Cook <keescook@...omium.org>,
Phillip Lougher <phillip@...ashfs.org.uk>,
Jan Kara <jack@...e.com>, linux-block@...r.kernel.org,
dm-devel@...hat.com, drbd-dev@...ts.linbit.com,
linux-bcache@...r.kernel.org, linux-raid@...r.kernel.org,
linux-nvme@...ts.infradead.org, linux-scsi@...r.kernel.org,
target-devel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-btrfs@...r.kernel.org, linux-ext4@...r.kernel.org,
jfs-discussion@...ts.sourceforge.net, linux-nfs@...r.kernel.org,
linux-nilfs@...r.kernel.org, linux-ntfs-dev@...ts.sourceforge.net,
ntfs3@...ts.linux.dev, reiserfs-devel@...r.kernel.org,
Chaitanya Kulkarni <kch@...dia.com>
Subject: [PATCH 25/30] 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@....de>
Reviewed-by: Kees Cook <keescook@...omium.org>
Reviewed-by: Chaitanya Kulkarni <kch@...dia.com>
---
include/linux/genhd.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index b560aee1d69f0..7a48d3ac725f3 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -250,6 +250,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);
--
2.30.2
Powered by blists - more mailing lists