Skip to content

Commit 1dc1f92

Browse files
committed
Merge tag 'for-5.16/bdev-size-2021-11-09' of git://git.kernel.dk/linux-block
Pull more bdev size updates from Jens Axboe: "Two followup changes for the bdev-size series from this merge window: - Add loff_t cast to bdev_nr_bytes() (Christoph) - Use bdev_nr_bytes() consistently for the block parts at least (me)" * tag 'for-5.16/bdev-size-2021-11-09' of git://git.kernel.dk/linux-block: block: use new bdev_nr_bytes() helper for blkdev_{read,write}_iter() block: add a loff_t cast to bdev_nr_bytes
2 parents 007301c + 138c1a3 commit 1dc1f92

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

block/fops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
527527
{
528528
struct block_device *bdev = iocb->ki_filp->private_data;
529529
struct inode *bd_inode = bdev->bd_inode;
530-
loff_t size = i_size_read(bd_inode);
530+
loff_t size = bdev_nr_bytes(bdev);
531531
struct blk_plug plug;
532532
size_t shorted = 0;
533533
ssize_t ret;
@@ -565,7 +565,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
565565
static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
566566
{
567567
struct block_device *bdev = iocb->ki_filp->private_data;
568-
loff_t size = i_size_read(bdev->bd_inode);
568+
loff_t size = bdev_nr_bytes(bdev);
569569
loff_t pos = iocb->ki_pos;
570570
size_t shorted = 0;
571571
ssize_t ret;

include/linux/genhd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static inline sector_t bdev_nr_sectors(struct block_device *bdev)
250250

251251
static inline loff_t bdev_nr_bytes(struct block_device *bdev)
252252
{
253-
return bdev_nr_sectors(bdev) << SECTOR_SHIFT;
253+
return (loff_t)bdev_nr_sectors(bdev) << SECTOR_SHIFT;
254254
}
255255

256256
static inline sector_t get_capacity(struct gendisk *disk)

0 commit comments

Comments
 (0)