diff options
author | Yu Kuai <yukuai3@huawei.com> | 2024-04-11 15:53:43 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2024-05-03 02:36:21 -0400 |
commit | 186ddac2072a8134798d72635d1ed0f29889369d (patch) | |
tree | dea5241d30fe11c82af0b94dcd4986503091a577 /block/bdev.c | |
parent | c9600c63a694249100e2bdcbb604c30d8fee2dc7 (diff) | |
download | linux-stable-186ddac2072a8134798d72635d1ed0f29889369d.tar.gz linux-stable-186ddac2072a8134798d72635d1ed0f29889369d.tar.bz2 linux-stable-186ddac2072a8134798d72635d1ed0f29889369d.zip |
block: move two helpers into bdev.c
disk_live() and block_size() access bd_inode directly, prepare to remove
the field bd_inode from block_device, and only access bd_inode in block
layer.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20240411145346.2516848-8-viro@zeniv.linux.org.uk
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'block/bdev.c')
-rw-r--r-- | block/bdev.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/block/bdev.c b/block/bdev.c index a89bce368b64..536233ac3e99 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -1257,6 +1257,18 @@ void bdev_statx_dioalign(struct inode *inode, struct kstat *stat) blkdev_put_no_open(bdev); } +bool disk_live(struct gendisk *disk) +{ + return !inode_unhashed(disk->part0->bd_inode); +} +EXPORT_SYMBOL_GPL(disk_live); + +unsigned int block_size(struct block_device *bdev) +{ + return 1 << bdev->bd_inode->i_blkbits; +} +EXPORT_SYMBOL_GPL(block_size); + static int __init setup_bdev_allow_write_mounted(char *str) { if (kstrtobool(str, &bdev_allow_write_mounted)) |