mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-11 15:49:56 +00:00
block: replace bd_set_size with bd_set_nr_sectors
Replace bd_set_size with a version that takes the number of sectors instead, as that fits most of the current and future callers much better. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
db04e18dbb
commit
611bee526b
@ -253,7 +253,7 @@ static void loop_set_size(struct loop_device *lo, loff_t size)
|
|||||||
{
|
{
|
||||||
struct block_device *bdev = lo->lo_device;
|
struct block_device *bdev = lo->lo_device;
|
||||||
|
|
||||||
bd_set_size(bdev, size << SECTOR_SHIFT);
|
bd_set_nr_sectors(bdev, size);
|
||||||
|
|
||||||
set_capacity_revalidate_and_notify(lo->lo_disk, size, false);
|
set_capacity_revalidate_and_notify(lo->lo_disk, size, false);
|
||||||
}
|
}
|
||||||
@ -1251,7 +1251,7 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
|
|||||||
set_capacity(lo->lo_disk, 0);
|
set_capacity(lo->lo_disk, 0);
|
||||||
loop_sysfs_exit(lo);
|
loop_sysfs_exit(lo);
|
||||||
if (bdev) {
|
if (bdev) {
|
||||||
bd_set_size(bdev, 0);
|
bd_set_nr_sectors(bdev, 0);
|
||||||
/* let user-space know about this change */
|
/* let user-space know about this change */
|
||||||
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
|
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
|
||||||
}
|
}
|
||||||
|
@ -300,6 +300,7 @@ static void nbd_size_update(struct nbd_device *nbd)
|
|||||||
{
|
{
|
||||||
struct nbd_config *config = nbd->config;
|
struct nbd_config *config = nbd->config;
|
||||||
struct block_device *bdev = bdget_disk(nbd->disk, 0);
|
struct block_device *bdev = bdget_disk(nbd->disk, 0);
|
||||||
|
sector_t nr_sectors = config->bytesize >> 9;
|
||||||
|
|
||||||
if (config->flags & NBD_FLAG_SEND_TRIM) {
|
if (config->flags & NBD_FLAG_SEND_TRIM) {
|
||||||
nbd->disk->queue->limits.discard_granularity = config->blksize;
|
nbd->disk->queue->limits.discard_granularity = config->blksize;
|
||||||
@ -308,10 +309,10 @@ static void nbd_size_update(struct nbd_device *nbd)
|
|||||||
}
|
}
|
||||||
blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
|
blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
|
||||||
blk_queue_physical_block_size(nbd->disk->queue, config->blksize);
|
blk_queue_physical_block_size(nbd->disk->queue, config->blksize);
|
||||||
set_capacity(nbd->disk, config->bytesize >> 9);
|
set_capacity(nbd->disk, nr_sectors);
|
||||||
if (bdev) {
|
if (bdev) {
|
||||||
if (bdev->bd_disk) {
|
if (bdev->bd_disk) {
|
||||||
bd_set_size(bdev, config->bytesize);
|
bd_set_nr_sectors(bdev, nr_sectors);
|
||||||
set_blocksize(bdev, config->blksize);
|
set_blocksize(bdev, config->blksize);
|
||||||
} else
|
} else
|
||||||
bdev->bd_invalidated = 1;
|
bdev->bd_invalidated = 1;
|
||||||
@ -1138,7 +1139,7 @@ static void nbd_bdev_reset(struct block_device *bdev)
|
|||||||
{
|
{
|
||||||
if (bdev->bd_openers > 1)
|
if (bdev->bd_openers > 1)
|
||||||
return;
|
return;
|
||||||
bd_set_size(bdev, 0);
|
bd_set_nr_sectors(bdev, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nbd_parse_flags(struct nbd_device *nbd)
|
static void nbd_parse_flags(struct nbd_device *nbd)
|
||||||
|
@ -2192,7 +2192,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
|
|||||||
|
|
||||||
set_capacity(pd->disk, lba << 2);
|
set_capacity(pd->disk, lba << 2);
|
||||||
set_capacity(pd->bdev->bd_disk, lba << 2);
|
set_capacity(pd->bdev->bd_disk, lba << 2);
|
||||||
bd_set_size(pd->bdev, (loff_t)lba << 11);
|
bd_set_nr_sectors(pd->bdev, lba << 2);
|
||||||
|
|
||||||
q = bdev_get_queue(pd->bdev);
|
q = bdev_get_queue(pd->bdev);
|
||||||
if (write) {
|
if (write) {
|
||||||
|
@ -688,7 +688,7 @@ static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
|
|||||||
struct block_device *bdev = bdget_disk(disk, 0);
|
struct block_device *bdev = bdget_disk(disk, 0);
|
||||||
|
|
||||||
if (bdev) {
|
if (bdev) {
|
||||||
bd_set_size(bdev, get_capacity(disk) << SECTOR_SHIFT);
|
bd_set_nr_sectors(bdev, get_capacity(disk));
|
||||||
bdput(bdev);
|
bdput(bdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1371,13 +1371,13 @@ int check_disk_change(struct block_device *bdev)
|
|||||||
|
|
||||||
EXPORT_SYMBOL(check_disk_change);
|
EXPORT_SYMBOL(check_disk_change);
|
||||||
|
|
||||||
void bd_set_size(struct block_device *bdev, loff_t size)
|
void bd_set_nr_sectors(struct block_device *bdev, sector_t sectors)
|
||||||
{
|
{
|
||||||
inode_lock(bdev->bd_inode);
|
inode_lock(bdev->bd_inode);
|
||||||
i_size_write(bdev->bd_inode, size);
|
i_size_write(bdev->bd_inode, (loff_t)sectors << SECTOR_SHIFT);
|
||||||
inode_unlock(bdev->bd_inode);
|
inode_unlock(bdev->bd_inode);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(bd_set_size);
|
EXPORT_SYMBOL(bd_set_nr_sectors);
|
||||||
|
|
||||||
static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part);
|
static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part);
|
||||||
|
|
||||||
@ -1514,7 +1514,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, void *holder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
|
bd_set_nr_sectors(bdev, get_capacity(disk));
|
||||||
set_init_blocksize(bdev);
|
set_init_blocksize(bdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1542,7 +1542,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, void *holder,
|
|||||||
ret = -ENXIO;
|
ret = -ENXIO;
|
||||||
goto out_clear;
|
goto out_clear;
|
||||||
}
|
}
|
||||||
bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9);
|
bd_set_nr_sectors(bdev, bdev->bd_part->nr_sects);
|
||||||
set_init_blocksize(bdev);
|
set_init_blocksize(bdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ void unregister_blkdev(unsigned int major, const char *name);
|
|||||||
int revalidate_disk(struct gendisk *disk);
|
int revalidate_disk(struct gendisk *disk);
|
||||||
int check_disk_change(struct block_device *bdev);
|
int check_disk_change(struct block_device *bdev);
|
||||||
int __invalidate_device(struct block_device *bdev, bool kill_dirty);
|
int __invalidate_device(struct block_device *bdev, bool kill_dirty);
|
||||||
void bd_set_size(struct block_device *bdev, loff_t size);
|
void bd_set_nr_sectors(struct block_device *bdev, sector_t sectors);
|
||||||
|
|
||||||
/* for drivers/char/raw.c: */
|
/* for drivers/char/raw.c: */
|
||||||
int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
|
int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user