Skip to content

Commit

Permalink
libf2fs: Fix calculation of usable segments for single zoned
Browse files Browse the repository at this point in the history
There was a bug that did not subtract the super block area when calculating
the usable segments for a single zoned device with a conventional zone.
This bug resulted in incorrect the overprovision and reserved area.

	<256MiB legacy block + zoned block w/ 32MiB zone size>
	Info: Overprovision ratio = 3.570%
	Info: Overprovision segments = 656 (GC reserved = 560)

	<8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
	Info: Overprovision ratio = 3.700%
	Info: Overprovision segments = 676 (GC reserved = 578)

This patch fixes the bug by subtracting the super block area when there is
only one zoned device.

Signed-off-by: Yonggil Song <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
yonggilsong authored and Jaegeuk Kim committed Oct 7, 2024
1 parent c8de910 commit 6aaf95b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/libf2fs_zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
}
usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
get_sb(log_blocks_per_seg);

/* single zoned device needs to remove a super block area */
if (c.ndevs == 1)
usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));

return usable_segs;
#endif
return get_sb(segment_count_main);
Expand Down

0 comments on commit 6aaf95b

Please sign in to comment.