Skip to content

Commit

Permalink
mkfs.f2fs: adjust zone alignment when using convention partition with…
Browse files Browse the repository at this point in the history
… zoned one

When formatting conventional partition with zoned one, we are already
aligning the starting block address of the next device to the zone size.
Therefore, we do not align the segment0 address to the zone alignment.
This reduces the wasted zone_align_start_offset.

Test result
segment0 blkaddr 389583 -> 119251
Add one additional section to main

Signed-off-by: Yohan Joung <[email protected]>
Reviewed-by: Daeho Jeong <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Yohan Joung authored and Jaegeuk Kim committed Oct 29, 2024
1 parent b7b6cac commit 2893f7c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mkfs/f2fs_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ static int f2fs_prepare_super_block(void)
uint32_t log_sectorsize, log_sectors_per_block;
uint32_t log_blocksize, log_blks_per_seg;
uint32_t segment_size_bytes, zone_size_bytes;
uint32_t alignment_bytes;
uint32_t sit_segments, nat_segments;
uint32_t blocks_for_sit, blocks_for_nat, blocks_for_ssa;
uint32_t total_valid_blks_available;
Expand Down Expand Up @@ -305,10 +306,12 @@ static int f2fs_prepare_super_block(void)

set_sb(block_count, c.total_sectors >> log_sectors_per_block);

alignment_bytes = c.zoned_mode && c.ndevs > 1 ? segment_size_bytes : zone_size_bytes;

zone_align_start_offset =
((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE +
2 * F2FS_BLKSIZE + zone_size_bytes - 1) /
zone_size_bytes * zone_size_bytes -
2 * F2FS_BLKSIZE + alignment_bytes - 1) /
alignment_bytes * alignment_bytes -
(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;

if (c.feature & F2FS_FEATURE_RO)
Expand All @@ -327,7 +330,8 @@ static int f2fs_prepare_super_block(void)

if (c.zoned_mode && c.ndevs > 1)
zone_align_start_offset +=
(c.devices[0].total_sectors * c.sector_size) % zone_size_bytes;
(c.devices[0].total_sectors * c.sector_size -
zone_align_start_offset) % zone_size_bytes;

set_sb(segment0_blkaddr, zone_align_start_offset / blk_size_bytes);
sb->cp_blkaddr = sb->segment0_blkaddr;
Expand Down

0 comments on commit 2893f7c

Please sign in to comment.