[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211013051042.1065752-25-hch@lst.de>
Date: Wed, 13 Oct 2021 07:10:37 +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-mtd@...ts.infradead.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
Subject: [PATCH 24/29] 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. Note that SECTOR_SHIFT has to be open coded due to
include dependency issues for now, but I have a plan to sort that out
eventually.
Signed-off-by: Christoph Hellwig <hch@....de>
---
include/linux/genhd.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 082a3e5fd8fa1..6eaef8fa78bcd 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -245,6 +245,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 - 9 /* 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