On 2020/9/16 9:54, Xiaojun Wang wrote:
Meta area is not included in section_count computation.
The code in mkfs/f2fs_format.c is:
        total_zones = get_sb(segment_count) / (c.segs_per_zone) -
                                        total_meta_zones;
        set_sb(section_count, total_zones * c.secs_per_zone);

So the minimum total_sections is 1.

Signed-off-by: Xiaojun Wang <[email protected]>
---
  fs/f2fs/super.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index dfa072fa8081..a450c8589841 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2799,8 +2799,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info 
*sbi,
                return -EFSCORRUPTED;
        }
- if (total_sections > segment_count ||
-                       total_sections < F2FS_MIN_SEGMENTS ||
+       if (total_sections > segment_count || total_sections < 1 ||
                        segs_per_sec > segment_count || !segs_per_sec) {

Here, we try to check sanity on segs_per_sec config directly and indirectly:
- directly: check raw_super->segs_per_sec field
- indirectly: check whether segment_count / total_sections is less than 1

So I guess that first condition is wrong as well, should change it like?

if (total_sections > segment_count - 'total_meta_segment_count' ||

Thoughts?

Thanks,

                f2fs_info(sbi, "Invalid segment/section count (%u, %u x %u)",
                          segment_count, total_sections, segs_per_sec);



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to