[Ocfs2-tools-devel] [PATCH 1/2] fsck: fix the first group desc in chain 0 when globalbitmap has only one chain

piaojun piaojun at huawei.com
Mon Sep 11 23:12:44 PDT 2017



On 2017/9/12 13:57, Joseph Qi wrote:
> 
> 
> On 17/9/12 08:50, piaojun wrote:
>>
>>
>> On 2017/9/11 19:19, Joseph Qi wrote:
>>>
>>> Hi Jun,
>>>
>>> On 17/9/10 11:15, piaojun wrote:
>>>> fsck can't fix the first group desc in chain 0 when global_bitmap has
>>>> only one chain, because we will get error when reading gd in
>>>> maybe_fix_clusters_per_group(). so we need fix the corrupted gd in the
>>>> following steps.
>>>>
>>>> Signed-off-by: Jun Piao <piaojun at huawei.com>
>>>> ---
>>>>  fsck.ocfs2/pass0.c | 14 +++++++++++---
>>>>  1 file changed, 11 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/fsck.ocfs2/pass0.c b/fsck.ocfs2/pass0.c
>>>> index 148877c..bfd11fb 100644
>>>> --- a/fsck.ocfs2/pass0.c
>>>> +++ b/fsck.ocfs2/pass0.c
>>>> @@ -635,7 +635,15 @@ static errcode_t maybe_fix_clusters_per_group(o2fsck_state *ost,
>>>>  	blkno = cl->cl_recs[0].c_blkno;
>>>>
>>>>  	ret = ocfs2_read_group_desc(ost->ost_fs, blkno, (char *)gd);
>>>> -	if (ret) {
>>>> +	if ((ret == OCFS2_ET_BAD_GROUP_DESC_MAGIC) ||
>>>> +	    (!ret && gd->bg_generation != ost->ost_fs_generation)) {
>>>
>>> IIRC, ocfs2_read_group_desc will validate gd after read. So could you
>>> please describe in which case the return value is 0 while generation is
>>> corrupt?
>>>
>>> Thanks,
>>> Joseph
>>>
>> ocfs2_read_group_desc() will only validate gd signature, so if
>> the signature is normal but the generation is corrupt for some reasons,
>> e.g., file system bug. the return value will be 0.
>>
>> Thanks,
>> Jun
>>
> IC, thanks for the explanation.
> One more question, if now let it go further, can we fix this corrupt in
> current fsck logic?
> 
> Thanks,
> Joseph
> 
On my test, the corrupt gd will be fixed in the following steps:
o2fsck_pass0()
  verify_bitmap_descs()
Thanks,
Jun



More information about the Ocfs2-tools-devel mailing list