mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH] mkfs.f2fs: fix to align RO image layout w/ block size
Date: Thu, 22 Oct 2026 13:12:48 +0000	[thread overview]
Message-ID: <20261022131248.3440239-1-chao@kernel.org> (raw)

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


                 reply	other threads:[~2026-10-22 13:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261022131248.3440239-1-chao@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®