mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one
@ 2024-10-29 13:45 Yohan Joung
  2024-10-29 16:53 ` Daeho Jeong
  2024-11-05  1:54 ` Chao Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Yohan Joung @ 2024-10-29 13:45 UTC (permalink / raw)
  To: jaegeuk, chao, daeho43; +Cc: linux-f2fs-devel, linux-kernel, Yohan Joung

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 <yohan.joung@sk.com>
---
 mkfs/f2fs_format.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index a01b19e..52a1e18 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -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;
@@ -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)
@@ -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;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one
  2024-10-29 13:45 [PATCH v2] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one Yohan Joung
@ 2024-10-29 16:53 ` Daeho Jeong
  2024-11-05  1:54 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Daeho Jeong @ 2024-10-29 16:53 UTC (permalink / raw)
  To: Yohan Joung; +Cc: jaegeuk, chao, linux-f2fs-devel, linux-kernel, Yohan Joung

Reviewed-by: Daeho Jeong <daehojeong@google.com>

Thanks,

On Tue, Oct 29, 2024 at 6:45 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.
>
> Test result
> segment0 blkaddr 389583 -> 119251
> Add one additional section to main
>
> Signed-off-by: Yohan Joung <yohan.joung@sk.com>
> ---
>  mkfs/f2fs_format.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index a01b19e..52a1e18 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -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;
> @@ -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)
> @@ -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;
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one
  2024-10-29 13:45 [PATCH v2] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one Yohan Joung
  2024-10-29 16:53 ` Daeho Jeong
@ 2024-11-05  1:54 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2024-11-05  1:54 UTC (permalink / raw)
  To: Yohan Joung, jaegeuk, daeho43
  Cc: Chao Yu, linux-f2fs-devel, linux-kernel, Yohan Joung

On 2024/10/29 21:45, Yohan Joung 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.
> 
> Test result
> segment0 blkaddr 389583 -> 119251
> Add one additional section to main
> 
> Signed-off-by: Yohan Joung <yohan.joung@sk.com>
> ---
>   mkfs/f2fs_format.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index a01b19e..52a1e18 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -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;
> @@ -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  -

round_up(..., alignment_bytes) * alignment_bytes - ?

Otherwise, it looks good to me.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

>   		(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
>   
>   	if (c.feature & F2FS_FEATURE_RO)
> @@ -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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-05  1:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-29 13:45 [PATCH v2] mkfs.f2fs: adjust zone alignment when using convention partition with zoned one Yohan Joung
2024-10-29 16:53 ` Daeho Jeong
2024-11-05  1:54 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®