* [PATCH] mkfs.f2fs: fix to align RO image layout w/ block size
@ 2026-10-22 13:12 Chao Yu
0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2026-10-22 13:12 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
From: Chao Yu <chao@kernel.org>
f2fs/015 fails w/ 16k block size, mounting an image formatted w/
"-O ro" fails as below:
mkfs.f2fs -f -b 16384 -O ro /dev/vdd
mount -t f2fs -o ro /dev/vdd /mnt/f2fs
mount: /mnt/f2fs: mount() failed: Structure needs cleaning.
F2FS-fs (vdd): invalid crc_offset: 0
F2FS-fs (vdd): Skip to start discard thread for readonly image
F2FS-fs (vdd): SIT is corrupted node# 0 vs 1
F2FS-fs (vdd): Failed to initialize F2FS segment manager (-117)
and fsck.f2fs reports:
[ASSERT] (fsck_chk_curseg_info:3747) --> Incorrect curseg [3]: segno [0x38] type(SIT) [0]
For RO image, f2fs_prepare_super_block() hardcodes the start offset of
segment0 to 8192 bytes, i.e. two 4k blocks for the two superblocks, but
w/ 16k block size, 8192 bytes is only half of a block, so segment0_blkaddr
and cp_blkaddr become 0, then the 1st checkpoint pack shares block #0 w/
the superblock and is overwritten by it, so kernel and fsck can not find
valid SIT journal entries in the compacted summary.
Let's use 2 * F2FS_BLKSIZE as the start offset instead.
Fixes: 50fd00b ("f2fs-tools: Support different block sizes")
Signed-off-by: Chao Yu <chao@kernel.org>
---
mkfs/f2fs_format.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 33d3da9..7390fa4 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -316,7 +316,7 @@ static int f2fs_prepare_super_block(void)
(uint64_t) c.start_sector * DEFAULT_SECTOR_SIZE;
if (c.feature & F2FS_FEATURE_RO)
- zone_align_start_offset = 8192;
+ zone_align_start_offset = 2 * F2FS_BLKSIZE;
if (c.start_sector % DEFAULT_SECTORS_PER_BLOCK) {
MSG(1, "\t%s: Align start sector number to the page unit\n",
--
2.49.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-22 13:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 13:12 [PATCH] mkfs.f2fs: fix to align RO image layout w/ block size 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®