Thread (76 messages) 76 messages, 15 authors, 2021-10-14
STALE1688d

[PATCH 23/29] block: use bdev_nr_sectors instead of open coding it in blkdev_fallocate

From: Christoph Hellwig <hch@lst.de>
Date: 2021-10-13 05:42:21
Also in: dm-devel, linux-bcache, linux-block, linux-btrfs, linux-fsdevel, linux-nfs, linux-nvme, linux-raid, linux-scsi, ntfs3, target-devel
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

Use the proper helper to read the block device size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/fops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/fops.c b/block/fops.c
index 7bb9581a146cf..6e27dd2748504 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_sectors(bdev) << SECTOR_SHIFT;
 	if (start >= isize)
 		return -EINVAL;
 	if (end >= isize) {
-- 
2.30.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help