All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] mkfs.f2fs: align each device to zone size
@ 2024-04-10 12:38 Sheng Yong via Linux-f2fs-devel
  2024-04-30  1:04 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Sheng Yong via Linux-f2fs-devel @ 2024-04-10 12:38 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

For multiple device, each device should be aligned to zone size, instead
of aligning the total size.

Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
 mkfs/f2fs_format.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 8f632f8..9e1b0d6 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -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 +
@@ -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) +
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2024-04-30  1:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-10 12:38 [f2fs-dev] [PATCH] mkfs.f2fs: align each device to zone size Sheng Yong via Linux-f2fs-devel
2024-04-30  1:04 ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.