在 2020/9/16 17:49, Yuchao (T) 写道:
> On 2020/9/16 14:56, wangxiaojun (N) wrote:
>> 在 2020/9/16 10:57, Yuchao (T) 写道:
>>> 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,
>> Hi Chao, aggree with you.
>>
>> 'total_meta_segment_count' = le32_to_cpu(raw_super->segment_count_ckpt) +
>>                      le32_to_cpu(raw_super->segment_count_sit) +
>>                      le32_to_cpu(raw_super->segment_count_nat) +
>>                      le32_to_cpu(raw_super->segment_count_ssa)
>> But the above values will be checked in sanity_check_area_boundary() which 
>> will be called later.
>> So can we move the total_sections checking to sanity_check_area_boundary
> I think we'd better keep segs_per_sec check in sanity_check_raw_super(), as
> it's a field of superblock.
OK
>>   ensure the 'total_meta_segment_count' is correct ?
> It looks the condition below is wrong as well for the same reason you 
> mentioned
> in commit message?
>
> if (unlikely(fsmeta < F2FS_MIN_SEGMENTS ||
>
> Thanks,

Will updated in V2

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