Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <hch@lst.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Anton Altaparmakov <anton@tuxera.com>
Link: https://lore.kernel.org/r/20211018101130.1838532-29-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
ab700417 dd0c0bdf

+3 -5
+3 -5
fs/ntfs/super.c
··· 2772 2772 ntfs_debug("Set device block size to %i bytes (block size bits %i).", 2773 2773 blocksize, sb->s_blocksize_bits); 2774 2774 /* 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) { 2776 2777 if (!silent) 2777 2778 ntfs_error(sb, "Unable to determine device size."); 2778 2779 goto err_out_now; 2779 2780 } 2780 - vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> 2781 - sb->s_blocksize_bits; 2782 2781 /* Read the boot sector and return unlocked buffer head to it. */ 2783 2782 if (!(bh = read_ntfs_boot_sector(sb, silent))) { 2784 2783 if (!silent) ··· 2815 2816 goto err_out_now; 2816 2817 } 2817 2818 BUG_ON(blocksize != sb->s_blocksize); 2818 - vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> 2819 - sb->s_blocksize_bits; 2819 + vol->nr_blocks = sb_bdev_nr_blocks(sb); 2820 2820 ntfs_debug("Changed device block size to %i bytes (block size " 2821 2821 "bits %i) to match volume sector size.", 2822 2822 blocksize, sb->s_blocksize_bits);