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

Re: [PATCH 12/29] cramfs: use bdev_nr_sectors instead of open coding it

From: Kees Cook <hidden>
Date: 2021-10-13 06:16:16
Also in: dm-devel, linux-bcache, linux-block, linux-btrfs, linux-fsdevel, linux-nfs, linux-nvme, linux-raid, linux-scsi, ntfs3, target-devel

On Wed, Oct 13, 2021 at 07:10:25AM +0200, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
Use the proper helper to read the block device size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/cramfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 2be65269a987c..3e44cc3ed0543 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -209,7 +209,7 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
 		return read_buffers[i] + blk_offset;
 	}
 
-	devsize = mapping->host->i_size >> PAGE_SHIFT;
+	devsize = bdev_nr_sectors(sb->s_bdev) >> (PAGE_SHIFT - SECTOR_SHIFT);
I find this less readable than "bytes >> PAGE_SHIFT". I'd suggest this
use a new bdev_nr_bytes() helper.

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help