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 <c...@kernel.org>
---
 lib/libf2fs_zoned.c | 8 ++++++++
 1 file changed, 8 insertions(+)

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;
-- 
2.48.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to