Skip to content

Commit d46db45

Browse files
mcgrofJaegeuk Kim
authored andcommitted
f2fs: call bdev_zone_sectors() only once on init_blkz_info()
Instead of calling bdev_zone_sectors() multiple times, call it once and cache the value locally. This will make the subsequent change easier to read. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 4de8514 commit d46db45

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

fs/f2fs/super.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,22 +3651,25 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
36513651
struct block_device *bdev = FDEV(devi).bdev;
36523652
sector_t nr_sectors = bdev_nr_sectors(bdev);
36533653
struct f2fs_report_zones_args rep_zone_arg;
3654+
u64 zone_sectors;
36543655
int ret;
36553656

36563657
if (!f2fs_sb_has_blkzoned(sbi))
36573658
return 0;
36583659

3660+
zone_sectors = bdev_zone_sectors(bdev);
3661+
36593662
if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
3660-
SECTOR_TO_BLOCK(bdev_zone_sectors(bdev)))
3663+
SECTOR_TO_BLOCK(zone_sectors))
36613664
return -EINVAL;
3662-
sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_sectors(bdev));
3665+
sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors);
36633666
if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz !=
36643667
__ilog2_u32(sbi->blocks_per_blkz))
36653668
return -EINVAL;
36663669
sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
36673670
FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
36683671
sbi->log_blocks_per_blkz;
3669-
if (nr_sectors & (bdev_zone_sectors(bdev) - 1))
3672+
if (nr_sectors & (zone_sectors - 1))
36703673
FDEV(devi).nr_blkz++;
36713674

36723675
FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,

0 commit comments

Comments
 (0)