Message ID | 20240910135636.471-1-yohan.joung@sk.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [f2fs-dev] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one | expand |
On Tue, Sep 10, 2024 at 6:58 AM Yohan Joung <jyh429@gmail.com> wrote: > > 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. > > Signed-off-by: Yohan Joung <yohan.joung@sk.com> > --- > mkfs/f2fs_format.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c > index 37d23f3..71f5ec8 100644 > --- a/mkfs/f2fs_format.c > +++ b/mkfs/f2fs_format.c > @@ -252,11 +252,19 @@ static int f2fs_prepare_super_block(void) > > set_sb(block_count, c.total_sectors >> log_sectors_per_block); > > - 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 - > - (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; > + if (c.zoned_mode && c.ndevs > 1) { > + zone_align_start_offset = > + ((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE + > + 2 * F2FS_BLKSIZE + segment_size_bytes - 1) / > + segment_size_bytes * segment_size_bytes - > + (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; > + } else { > + 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 - > + (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; > + } How about using a variable like "alignment_bytes" to accommodate both "segment_size_bytes" and "zone_size_bytes"? zone_align_start_offset = ((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE + 2 * F2FS_BLKSIZE + alignment_bytes - 1) / alignment_bytes * alignment_bytes - (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; Thanks, > > if (c.feature & F2FS_FEATURE_RO) > zone_align_start_offset = 8192; > -- > 2.25.1 > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 37d23f3..71f5ec8 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -252,11 +252,19 @@ static int f2fs_prepare_super_block(void) set_sb(block_count, c.total_sectors >> log_sectors_per_block); - 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 - - (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; + if (c.zoned_mode && c.ndevs > 1) { + zone_align_start_offset = + ((uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE + + 2 * F2FS_BLKSIZE + segment_size_bytes - 1) / + segment_size_bytes * segment_size_bytes - + (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; + } else { + 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 - + (uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE; + } if (c.feature & F2FS_FEATURE_RO) zone_align_start_offset = 8192;
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. Signed-off-by: Yohan Joung <yohan.joung@sk.com> --- mkfs/f2fs_format.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)