Skip to contentSkip to conversation

fsck.f2fs: fix alignment on multi-partition support

PATCH New Jaegeuk Kim 1 participant 3 messages Dec 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 fsck.f2fs: fix alignment on multi-partition support

- mkfs.f2fs -s 4 -c second_dev first_dev
- fsck.f2fs first

Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 69668488 (34017 MB)
Segment count (19128) mismatch with total segments from devices (19130) Can't find a valid F2FS superblock at 0x0
Segment count (19128) mismatch with total segments from devices (19130) Can't find a valid F2FS superblock at 0x1

---
 fsck/mount.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fsck/mount.c +3 -2
index fc3ecb959737..6b2f17ebe8f3 100644
@@ -793,7 +793,7 @@ static int verify_sb_chksum(struct f2fs_super_block *sb)
 int sanity_check_raw_super(struct f2fs_super_block *sb, enum SB_ADDR sb_addr)
 {
 	unsigned int blocksize;
-	unsigned int segment_count, segs_per_sec, secs_per_zone;
+	unsigned int segment_count, segs_per_sec, secs_per_zone, segs_per_zone;
 	unsigned int total_sections, blocks_per_seg;
 
 	if ((get_sb(feature) & F2FS_FEATURE_SB_CHKSUM) &&
@@ -845,6 +845,7 @@ int sanity_check_raw_super(struct f2fs_super_block *sb, enum SB_ADDR sb_addr)
 	segs_per_sec = get_sb(segs_per_sec);
 	secs_per_zone = get_sb(secs_per_zone);
 	total_sections = get_sb(section_count);
+	segs_per_zone = segs_per_sec * secs_per_zone;
 
 	/* blocks_per_seg should be 512, given the above check */
 	blocks_per_seg = 1 << get_sb(log_blocks_per_seg);
@@ -883,7 +884,7 @@ int sanity_check_raw_super(struct f2fs_super_block *sb, enum SB_ADDR sb_addr)
 			dev_segs += le32_to_cpu(sb->devs[i].total_segments);
 			i++;
 		}
-		if (segment_count != dev_segs) {
+		if (segment_count != dev_segs / segs_per_zone * segs_per_zone) {
 			MSG(0, "Segment count (%u) mismatch with total segments from devices (%u)",
 				segment_count, dev_segs);
 			return 1;
Signature · 8 lines
2.29.2.729.g45daf8777d-goog



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

PATCH 3/3 mkfs.f2fs: allocate zones together to avoid random access

This patch allocates zones to initial logs together, if it's on zoned device.

---
 mkfs/f2fs_format.c | 7 +++++++
 1 file changed, 7 insertions(+)
mkfs/f2fs_format.c +7 -0
index f60dcc029d58..b4bec92a24d9 100644
@@ -510,6 +510,13 @@ static int f2fs_prepare_super_block(void)
 		c.cur_seg[CURSEG_HOT_DATA] = prev_zone(CURSEG_COLD_NODE);
 		c.cur_seg[CURSEG_COLD_DATA] = 0;
 		c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
+	} else if (c.zoned_mode) {
+		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
+		c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
+		c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
+		c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_HOT_DATA);
+		c.cur_seg[CURSEG_COLD_DATA] = next_zone(CURSEG_WARM_DATA);
 	} else {
 		c.cur_seg[CURSEG_HOT_NODE] = 0;
 		c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
Signature · 8 lines
2.29.2.729.g45daf8777d-goog



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

PATCH 2/3 mkfs.f2fs: adjust zone alignment when using multi-partitions

In reply to Jaegeuk Kim

When formatting conventional partition with zoned one, we should align the starting block address of next device to the zone size.

---
 mkfs/f2fs_format.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +10 -2
index a6c542e8e1f0..f60dcc029d58 100644
@@ -254,14 +254,22 @@ static int f2fs_prepare_super_block(void)
 			return -1;
 	}
 
+	if (c.zoned_mode && c.ndevs > 1)
+		zone_align_start_offset +=
+			(c.devices[0].total_sectors * c.sector_size) % zone_size_bytes;
+
 	set_sb(segment0_blkaddr, zone_align_start_offset / blk_size_bytes);
 	sb->cp_blkaddr = sb->segment0_blkaddr;
 
 	MSG(0, "Info: zone aligned segment0 blkaddr: %u\n",
 					get_sb(segment0_blkaddr));
 
-	if (c.zoned_mode && (get_sb(segment0_blkaddr) + c.start_sector /
-					DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) {
+	if (c.zoned_mode &&
+		((c.ndevs == 1 &&
+			(get_sb(segment0_blkaddr) + c.start_sector /
+			DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) ||
+		(c.ndevs > 1 &&
+			c.devices[1].start_blkaddr % c.zone_blocks))) {
 		MSG(1, "\tError: Unaligned segment0 block address %u\n",
 				get_sb(segment0_blkaddr));
 		return -1;
Signature · 8 lines
2.29.2.729.g45daf8777d-goog



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