mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 08:03:01 +09:00
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>
This commit is contained in:
committed by
Jens Axboe
parent
55793ea54d
commit
83794367dc
@@ -428,6 +428,14 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)
|
||||
return bdev;
|
||||
}
|
||||
|
||||
void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void bdev_add(struct block_device *bdev, dev_t dev)
|
||||
{
|
||||
bdev->bd_dev = dev;
|
||||
|
||||
Reference in New Issue
Block a user