[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 17:50:08 PDT 2017



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

>> +		if (prompt(ost, PY, PR_GROUP_EXPECTED_DESC,
>> +			    "Group descriptor at block %"PRIu64" is corrupted. "
>> +			    "Go fixing it in the following steps?", blkno)) {
>> +			ret = 0;
>> +		}
>> +		goto out;
>> +	} else if (ret) {
>>  		com_err(whoami, ret, "while reading group descriptor "
>>  			"at block %"PRIu64" to fix cl_cpg", blkno);
>>  		goto out;
>> @@ -1219,8 +1227,8 @@ static errcode_t verify_bitmap_descs(o2fsck_state *ost,
>>  		 * its values.. we only preserve the bitmap if the signature
>>  		 * and generation match this volume */
>>  		ret = ocfs2_read_group_desc(ost->ost_fs, blkno, (char *)bg);
>> -		if (ret == OCFS2_ET_BAD_GROUP_DESC_MAGIC ||
>> -		    bg->bg_generation != ost->ost_fs_generation) {
>> +		if ((ret == OCFS2_ET_BAD_GROUP_DESC_MAGIC) ||
>> +		    (!ret && bg->bg_generation != ost->ost_fs_generation)) {
>>  			memset(bg, 0, ost->ost_fs->fs_blocksize);
>>  			ocfs2_init_group_desc(ost->ost_fs, bg, blkno,
>>  					      ost->ost_fs_generation,
>>
> 



More information about the Ocfs2-tools-devel mailing list