Skip to contentSkip to conversation

mkfs.f2fs: adjust zone alignment when using convention partition with zoned one

PATCH Superseded Yohan Joung 2 participants 2 messages Sep 10, 2024 – Oct 28, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: adjust zone alignment when using convention partition with 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.

---
 mkfs/f2fs_format.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
mkfs/f2fs_format.c +13 -5
index 37d23f3..71f5ec8 100644
@@ -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;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 27 lines · 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.

---
 mkfs/f2fs_format.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
mkfs/f2fs_format.c +3 -5
index 37d23f3..71f5ec8 100644
@@ -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 +

mkfs/f2fs_format.c static int f2fs_prepare_super_block(void) · line 267

Quoted 10 lines
mkfs/f2fs_format.c +10 -0
+                       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,

Quoted 12 lines
mkfs/f2fs_format.c +0 -1
        if (c.feature & F2FS_FEATURE_RO)
                zone_align_start_offset = 8192;
--

2.25.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel