mkfs.f2fs: fix to calculate total segments correctly
PATCH 1/1 mkfs.f2fs: fix to calculate total segments correctly
1. create_null_blk.sh 512 2 1024 1024
"Created /dev/nullb0"
2. mkfs.f2fs -m /dev/nullb0
3. fsck.f2fs /dev/nullb0
"[FSCK] free segment_count matched with CP [Fail] [0x7e8, 0x7e7]"
For the case: there is only one host managed device, and the device has both convential zones and sequential zones, we didn't calculate total segments correctly, fix it.
Signed-off-by Chao Yu <[email protected]>
--- lib/libf2fs_zoned.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/libf2fs_zoned.c +8 -0
@@ -539,6 +539,14 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)return get_sb (segment_count_main);for (i =0 ; i < c.ndevs; i++) { +/* +* for the case: there is only one host managed device, and +* the device has both convential zones and sequential zones. +*/ +if (c.ndevs ==1 ) { + usable_segs += c.devices[i].total_segments; +break ; + }if (c.devices[i].zoned_model !=F2FS_ZONED_HM ) { usable_segs += c.devices[i].total_segments;continue ;
Signature · 8 lines
2.48.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel