public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_repair: fix process_bmbt_reclist_int
@ 2013-12-03 21:57 Ben Myers
  2013-12-03 23:08 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Myers @ 2013-12-03 21:57 UTC (permalink / raw)
  To: xfs

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.

Signed-off-by: Ben Myers <bpm@sgi.com>

---
 repair/dinode.c |    1 +
 1 file changed, 1 insertion(+)

Index: b/repair/dinode.c
===================================================================
--- a/repair/dinode.c	2013-12-03 15:43:59.895287548 -0600
+++ b/repair/dinode.c	2013-12-03 15:44:09.315225645 -0600
@@ -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
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs_repair: fix process_bmbt_reclist_int
  2013-12-03 21:57 [PATCH] xfs_repair: fix process_bmbt_reclist_int Ben Myers
@ 2013-12-03 23:08 ` Dave Chinner
  2013-12-03 23:14   ` Ben Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2013-12-03 23:08 UTC (permalink / raw)
  To: Ben Myers; +Cc: xfs

On Tue, Dec 03, 2013 at 03:57:35PM -0600, Ben Myers wrote:
> 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.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs_repair: fix process_bmbt_reclist_int
  2013-12-03 23:08 ` Dave Chinner
@ 2013-12-03 23:14   ` Ben Myers
  0 siblings, 0 replies; 3+ messages in thread
From: Ben Myers @ 2013-12-03 23:14 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Wed, Dec 04, 2013 at 10:08:04AM +1100, Dave Chinner wrote:
> On Tue, Dec 03, 2013 at 03:57:35PM -0600, Ben Myers wrote:
> > 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....

error2 it is.  Sounds good.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-03 23:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 21:57 [PATCH] xfs_repair: fix process_bmbt_reclist_int Ben Myers
2013-12-03 23:08 ` Dave Chinner
2013-12-03 23:14   ` Ben Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox