Skip to content

Commit

Permalink
f2fs: remove power-of-two limitation of zoned device
Browse files Browse the repository at this point in the history
In f2fs, there's no reason to force po2.

Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Jaegeuk Kim committed Apr 24, 2023
1 parent 5584785 commit 2e2c6e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,6 @@ struct f2fs_sb_info {

#ifdef CONFIG_BLK_DEV_ZONED
unsigned int blocks_per_blkz; /* F2FS blocks per zone */
unsigned int log_blocks_per_blkz; /* log2 F2FS blocks per zone */
#endif

/* for node-related operations */
Expand Down Expand Up @@ -4390,7 +4389,7 @@ F2FS_FEATURE_FUNCS(readonly, RO);
static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
block_t blkaddr)
{
unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
unsigned int zno = blkaddr / sbi->blocks_per_blkz;

return test_bit(zno, FDEV(devi).blkz_seq);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/f2fs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2093,8 +2093,8 @@ static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs)
FDEV(last_dev).end_blk =
(long long)FDEV(last_dev).end_blk + blks;
#ifdef CONFIG_BLK_DEV_ZONED
FDEV(last_dev).nr_blkz = (int)FDEV(last_dev).nr_blkz +
(int)(blks >> sbi->log_blocks_per_blkz);
FDEV(last_dev).nr_blkz = FDEV(last_dev).nr_blkz +
div_u64(blks, sbi->blocks_per_blkz);
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,

if (force && start >= cpc->trim_start &&
(end - 1) <= cpc->trim_end)
continue;
continue;

/* Should cover 2MB zoned device for zone-based reset */
if (!f2fs_sb_has_blkzoned(sbi) &&
Expand Down
8 changes: 2 additions & 6 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3806,12 +3806,8 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
SECTOR_TO_BLOCK(zone_sectors))
return -EINVAL;
sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors);
if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz !=
__ilog2_u32(sbi->blocks_per_blkz))
return -EINVAL;
sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
sbi->log_blocks_per_blkz;
FDEV(devi).nr_blkz = div_u64(SECTOR_TO_BLOCK(nr_sectors),
sbi->blocks_per_blkz);
if (nr_sectors & (zone_sectors - 1))
FDEV(devi).nr_blkz++;

Expand Down

0 comments on commit 2e2c6e9

Please sign in to comment.