# \[PATCH 24/30\] block: use bdev\_nr\_bytes instead of open coding it in blkdev\_fallocate

- From: Christoph Hellwig \<hch@lst.de\>
- Date: 2021-10-18 10:13:53 
- List: linux-ext4
- Page: https://ratatoskr.run/linux-ext4/2021/10/216220
- Thread: https://ratatoskr.run/linux-block/2021/10/216197/t.md

```text
Use the proper helper to read the block device size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kees Cook <redacted>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 block/fops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/fops.c b/block/fops.c
index 7bb9581a146cf..a6a4d412720cd 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -548,7 +548,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
 		return -EOPNOTSUPP;
 
 	/* Don't go off the end of the device. */
-	isize = i_size_read(bdev->bd_inode);
+	isize = bdev_nr_bytes(bdev);
 	if (start >= isize)
 		return -EINVAL;
 	if (end >= isize) {
-- 
2.30.2

```
