summaryrefslogtreecommitdiff
path: root/block/genhd.c
diff options
context:
space:
mode:
authorDamien Le Moal <dlemoal@kernel.org>2023-04-24 22:13:18 +0900
committerJens Axboe <axboe@kernel.dk>2023-04-24 08:48:09 -0600
commit83794367dcc6749662b17a1e4b8ec085023fc53b (patch)
tree25f3a27d3d30de07114aeb88ac0f8fcb29b12393 /block/genhd.c
parent55793ea54d77719a071b1ccc05a05056e3b5e009 (diff)
downloadlwn-83794367dcc6749662b17a1e4b8ec085023fc53b.tar.gz
lwn-83794367dcc6749662b17a1e4b8ec085023fc53b.zip
block: Cleanup set_capacity()/bdev_set_nr_sectors()
The code for setting a block device capacity (bd_nr_sectors field of struct block_device) is duplicated in set_capacity() and bdev_set_nr_sectors(). Clean this up by making bdev_set_nr_sectors() a block layer internal function defined in block/bdev.c instead of having this function statically defined in block/partitions/core.c. With this change, set_capacity() implementation can be simplified to only calling bdev_set_nr_sectors(). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230424131318.79935-1-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/block/genhd.c b/block/genhd.c
index cadcb472dfc3..8d56fb5f08b2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -57,12 +57,7 @@ static DEFINE_IDA(ext_devt_ida);
void set_capacity(struct gendisk *disk, sector_t sectors)
{
- struct block_device *bdev = disk->part0;
-
- spin_lock(&bdev->bd_size_lock);
- i_size_write(bdev->bd_inode, (loff_t)sectors << SECTOR_SHIFT);
- bdev->bd_nr_sectors = sectors;
- spin_unlock(&bdev->bd_size_lock);
+ bdev_set_nr_sectors(disk->part0, sectors);
}
EXPORT_SYMBOL(set_capacity);