Commit 138c1a38 authored by Jens Axboe's avatar Jens Axboe

block: use new bdev_nr_bytes() helper for blkdev_{read,write}_iter()

We have new helpers for this, use them rather than the slower inode
size reads. This makes the read/write path consistent with most of
the rest of block as well.
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/a72767cd-3c6d-47f7-80f4-aa025a17b2cb@kernel.dkSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2116274a
...@@ -460,7 +460,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -460,7 +460,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
{ {
struct block_device *bdev = iocb->ki_filp->private_data; struct block_device *bdev = iocb->ki_filp->private_data;
struct inode *bd_inode = bdev->bd_inode; struct inode *bd_inode = bdev->bd_inode;
loff_t size = i_size_read(bd_inode); loff_t size = bdev_nr_bytes(bdev);
struct blk_plug plug; struct blk_plug plug;
size_t shorted = 0; size_t shorted = 0;
ssize_t ret; ssize_t ret;
...@@ -498,7 +498,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -498,7 +498,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
{ {
struct block_device *bdev = iocb->ki_filp->private_data; struct block_device *bdev = iocb->ki_filp->private_data;
loff_t size = i_size_read(bdev->bd_inode); loff_t size = bdev_nr_bytes(bdev);
loff_t pos = iocb->ki_pos; loff_t pos = iocb->ki_pos;
size_t shorted = 0; size_t shorted = 0;
ssize_t ret; ssize_t ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment