Revert "resize.f2fs: add option for large_nat_bitmap feature"
This reverts commit daa0f8b9e9b1eea6c85e5c169b809254d9d7074e.
As Juhyung reported in [1]:
Here's what I did:
1. Remounted to checkpoint=disable
2. Create a dm-snapshot of the current root device
3. Mount snapshot to replay the log
4. Unmount
5. Resize sector 487248896 to 486539264
// ./resize.f2fs -d 3 -s -i /dev/mapper/snap -t 486539264
Latest f2fs-tools was used:
33c5b9539af2 f2fs_io: add fragread command to evaluate fragmented
buffer for reads
This reproduced the mount and fsck failure.
Mount log:
[442431.020594] F2FS-fs (dm-2): invalid crc_offset: 0
[442431.130055] F2FS-fs (dm-2): SIT is corrupted node# 13615201 vs 13616290
[442431.139684] F2FS-fs (dm-2): Failed to initialize F2FS segment manager (-117)
I checked below testcases:
truncate -s $((512*1024*1024*1024)) img
mkfs.f2fs -f img $((256*1024*1024))
Description Test command FSCK output
a) shrink w/ -s resize.f2fs -s -i img -t $((128*1024*1024)) Fine
b) expand w/ -s resize.f2fs -s -i img -t $((1024*1024*1024)) Corrupted
c) shrink w/o -s resize.f2fs -i img -t $((128*1024*1024)) No run
d) expand w/o -s resize.f2fs -i img -t $((1024*1024*1024)) Fine
Output from b):
[ASSERT] (check_block_count:2299) --> Wrong SIT valid blocks: segno=0x29400, 0 vs. 13
The root cause is: safe mode (-s option) is conflict w/ large nat bitmap feature
(-i option), since once we enable large nat bitmap, layout of checkpoint will be
changed [2], we must relocate nat/sit_bitmap to the end of new location of
cp_checksum, however in safe mode, we won't change metadata of checkpoint, so we
need to keep nat/sit_bitmap as it is, which includes checksum data in its old
location.
Let's revert -i support for resize.f2fs first, and then reenable it after
fix and well tested.
Thanks a lot for the help from Juhyung, including providing reproducer and
hints.
[1] https://lore.kernel.org/linux-f2fs-devel/CAD14+f3D6iPOBxEgkZxxTsXCfwRKb9ph68JtUk3H9cn8ovLt9w@mail.gmail.com/
[2] https://lore.kernel.org/linux-f2fs-devel/20190514093340.40217-2-yuchao0@huawei.com/
Fixes: daa0f8b ("resize.f2fs: add option for large_nat_bitmap feature")
Reported-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
3 files changed