Message ID | 20250324053639.2996261-1-chao@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [f2fs-dev] mkfs.f2fs: fix to calculate total segments correctly | expand |
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c index 89ba5ad..6730bba 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -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;
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 <chao@kernel.org> --- lib/libf2fs_zoned.c | 8 ++++++++ 1 file changed, 8 insertions(+)