mkfs.f2fs: fix to align RO image layout w/ block size
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>
1 file changed