Skip to content

Commit

Permalink
mkfs.f2fs: align each device to zone size
Browse files Browse the repository at this point in the history
For multiple device, each device should be aligned to zone size, instead
of aligning the total size.

Signed-off-by: Sheng Yong <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Sheng Yong authored and Jaegeuk Kim committed Apr 25, 2024
1 parent acaa173 commit 3b780e7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mkfs/f2fs_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,19 @@ static int f2fs_prepare_super_block(void)
for (i = 0; i < c.ndevs; i++) {
if (i == 0) {
c.devices[i].total_segments =
(c.devices[i].total_sectors *
((c.devices[i].total_sectors *
c.sector_size - zone_align_start_offset) /
segment_size_bytes;
segment_size_bytes) / c.segs_per_zone *
c.segs_per_zone;
c.devices[i].start_blkaddr = 0;
c.devices[i].end_blkaddr = c.devices[i].total_segments *
c.blks_per_seg - 1 +
sb->segment0_blkaddr;
} else {
c.devices[i].total_segments =
c.devices[i].total_sectors /
(c.sectors_per_blk * c.blks_per_seg);
(c.devices[i].total_sectors /
(c.sectors_per_blk * c.blks_per_seg)) /
c.segs_per_zone * c.segs_per_zone;
c.devices[i].start_blkaddr =
c.devices[i - 1].end_blkaddr + 1;
c.devices[i].end_blkaddr = c.devices[i].start_blkaddr +
Expand All @@ -321,8 +323,7 @@ static int f2fs_prepare_super_block(void)

c.total_segments += c.devices[i].total_segments;
}
set_sb(segment_count, (c.total_segments / c.segs_per_zone *
c.segs_per_zone));
set_sb(segment_count, c.total_segments);
set_sb(segment_count_ckpt, F2FS_NUMBER_OF_CHECKPOINT_PACK);

set_sb(sit_blkaddr, get_sb(segment0_blkaddr) +
Expand Down

0 comments on commit 3b780e7

Please sign in to comment.