Skip to content

Commit ab70041

Browse files
Christoph Hellwigaxboe
authored andcommitted
ntfs: use sb_bdev_nr_blocks
Use the sb_bdev_nr_blocks helper instead of open coding it and clean up ntfs_fill_super a bit by moving an assignment a little earlier that has no negative side effects. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Kees Cook <[email protected]> Acked-by: Anton Altaparmakov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dd0c0bd commit ab70041

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fs/ntfs/super.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,13 +2772,12 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
27722772
ntfs_debug("Set device block size to %i bytes (block size bits %i).",
27732773
blocksize, sb->s_blocksize_bits);
27742774
/* Determine the size of the device in units of block_size bytes. */
2775-
if (!i_size_read(sb->s_bdev->bd_inode)) {
2775+
vol->nr_blocks = sb_bdev_nr_blocks(sb);
2776+
if (!vol->nr_blocks) {
27762777
if (!silent)
27772778
ntfs_error(sb, "Unable to determine device size.");
27782779
goto err_out_now;
27792780
}
2780-
vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >>
2781-
sb->s_blocksize_bits;
27822781
/* Read the boot sector and return unlocked buffer head to it. */
27832782
if (!(bh = read_ntfs_boot_sector(sb, silent))) {
27842783
if (!silent)
@@ -2816,8 +2815,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
28162815
goto err_out_now;
28172816
}
28182817
BUG_ON(blocksize != sb->s_blocksize);
2819-
vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >>
2820-
sb->s_blocksize_bits;
2818+
vol->nr_blocks = sb_bdev_nr_blocks(sb);
28212819
ntfs_debug("Changed device block size to %i bytes (block size "
28222820
"bits %i) to match volume sector size.",
28232821
blocksize, sb->s_blocksize_bits);

0 commit comments

Comments
 (0)