Skip to content

Commit 2e2c6e9

Browse files
author
Jaegeuk Kim
committed
f2fs: remove power-of-two limitation of zoned device
In f2fs, there's no reason to force po2. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 5584785 commit 2e2c6e9

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

fs/f2fs/f2fs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,6 @@ struct f2fs_sb_info {
15231523

15241524
#ifdef CONFIG_BLK_DEV_ZONED
15251525
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
1526-
unsigned int log_blocks_per_blkz; /* log2 F2FS blocks per zone */
15271526
#endif
15281527

15291528
/* for node-related operations */
@@ -4390,7 +4389,7 @@ F2FS_FEATURE_FUNCS(readonly, RO);
43904389
static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
43914390
block_t blkaddr)
43924391
{
4393-
unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
4392+
unsigned int zno = blkaddr / sbi->blocks_per_blkz;
43944393

43954394
return test_bit(zno, FDEV(devi).blkz_seq);
43964395
}

fs/f2fs/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,8 +2093,8 @@ static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs)
20932093
FDEV(last_dev).end_blk =
20942094
(long long)FDEV(last_dev).end_blk + blks;
20952095
#ifdef CONFIG_BLK_DEV_ZONED
2096-
FDEV(last_dev).nr_blkz = (int)FDEV(last_dev).nr_blkz +
2097-
(int)(blks >> sbi->log_blocks_per_blkz);
2096+
FDEV(last_dev).nr_blkz = FDEV(last_dev).nr_blkz +
2097+
div_u64(blks, sbi->blocks_per_blkz);
20982098
#endif
20992099
}
21002100
}

fs/f2fs/segment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
20752075

20762076
if (force && start >= cpc->trim_start &&
20772077
(end - 1) <= cpc->trim_end)
2078-
continue;
2078+
continue;
20792079

20802080
/* Should cover 2MB zoned device for zone-based reset */
20812081
if (!f2fs_sb_has_blkzoned(sbi) &&

fs/f2fs/super.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,12 +3806,8 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
38063806
SECTOR_TO_BLOCK(zone_sectors))
38073807
return -EINVAL;
38083808
sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors);
3809-
if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz !=
3810-
__ilog2_u32(sbi->blocks_per_blkz))
3811-
return -EINVAL;
3812-
sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
3813-
FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
3814-
sbi->log_blocks_per_blkz;
3809+
FDEV(devi).nr_blkz = div_u64(SECTOR_TO_BLOCK(nr_sectors),
3810+
sbi->blocks_per_blkz);
38153811
if (nr_sectors & (zone_sectors - 1))
38163812
FDEV(devi).nr_blkz++;
38173813

0 commit comments

Comments
 (0)