Skip to contentSkip to conversation

xfs_repair: fix process_bmbt_reclist_int

PATCH Superseded Ben Myers 2 participants 3 messages Dec 3, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ben Myers

author
#0 lore raw

PATCH 1/1 xfs_repair: fix process_bmbt_reclist_int

There is a set checks for corruption in block map btrees in process_bmbt_reclist_int that we identify but currently do not fix. It appears that the author's intent in this function was to set error = 1, and then only clear it when all of the checks were completed successfully. Unfortunately error can be cleared when it is used for the return value of blkmap_set_ext. Some kinds of corruption are not being fixed, including duplicate extents, claiming free blocks, claiming metadata blocks, and multiply used blocks.

Fix this by shadowing error for blkmap_set_ext.

---
 repair/dinode.c |    1 +
 1 file changed, 1 insertion(+)
repair/dinode.c +1 -0
Index: b/repair/dinode.c
===================================================================
@@ -663,6 +663,7 @@ _("inode %" PRIu64 " - extent offset too
 		}
 
 		if (blkmapp && *blkmapp) {
+			int error;
 			error = blkmap_set_ext(blkmapp, irec.br_startoff,
 					irec.br_startblock, irec.br_blockcount);
 			if (error) {

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 10 lines · Ben Myers

There is a set checks for corruption in block map btrees in process_bmbt_reclist_int that we identify but currently do not fix. It appears that the author's intent in this function was to set error = 1, and then only clear it when all of the checks were completed successfully. Unfortunately error can be cleared when it is used for the return value of blkmap_set_ext. Some kinds of corruption are not being fixed, including duplicate extents, claiming free blocks, claiming metadata blocks, and multiply used blocks.

Fix this by shadowing error for blkmap_set_ext.

Shadowing variables is not a very nice way of solving the problem. Someone will come along in a couple of years anf go "huh?" and remove the shadowed declaration because it makes no sense and has no comments explaining it.

Better is to use a different variable name for this scope - say "error2" - or to reset error to a value of 1 after the call with a comment explaining it....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#2 lore raw
Quoted 12 lines · Dave Chinner
Quoted 10 lines · Ben Myers

There is a set checks for corruption in block map btrees in process_bmbt_reclist_int that we identify but currently do not fix. It appears that the author's intent in this function was to set error = 1, and then only clear it when all of the checks were completed successfully. Unfortunately error can be cleared when it is used for the return value of blkmap_set_ext. Some kinds of corruption are not being fixed, including duplicate extents, claiming free blocks, claiming metadata blocks, and multiply used blocks.

Fix this by shadowing error for blkmap_set_ext.

Quoted 8 lines

Shadowing variables is not a very nice way of solving the problem. Someone will come along in a couple of years anf go "huh?" and remove the shadowed declaration because it makes no sense and has no comments explaining it.

Better is to use a different variable name for this scope - say "error2" - or to reset error to a value of 1 after the call with a comment explaining it....

error2 it is. Sounds good.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs