linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs_repair: always release btree buffers when refcountbt checks fail
@ 2017-11-08  0:26 Darrick J. Wong
  2017-11-09  2:01 ` Dave Chinner
  0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2017-11-08  0:26 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

During phase 4 of repair, we compare the refcount records we've computed
against what's in the refcount btree.  If the btree is corrupt the
libxfs refcount calls will fail, but on our way out of the function we
don't make sure to clear all the btree cursor's buffer pointers.  This
leads to a repair deadlock in xfs/372 when fuzzing ptrs[1] to -1U
because we forgot to release a buffer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/rmap.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/repair/rmap.c b/repair/rmap.c
index 01d6f0f..d51590b 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -1359,7 +1359,8 @@ _("Incorrect reference count: saw (%u/%u) len %u nlinks %u; should be (%u/%u) le
 
 err:
 	if (bt_cur)
-		libxfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
+		libxfs_btree_del_cursor(bt_cur, error ? XFS_BTREE_ERROR :
+							XFS_BTREE_NOERROR);
 	if (agbp)
 		libxfs_putbuf(agbp);
 	free_slab_cursor(&rl_cur);

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

* Re: [PATCH] xfs_repair: always release btree buffers when refcountbt checks fail
  2017-11-08  0:26 [PATCH] xfs_repair: always release btree buffers when refcountbt checks fail Darrick J. Wong
@ 2017-11-09  2:01 ` Dave Chinner
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2017-11-09  2:01 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eric Sandeen, xfs

On Tue, Nov 07, 2017 at 04:26:36PM -0800, Darrick J. Wong wrote:
> During phase 4 of repair, we compare the refcount records we've computed
> against what's in the refcount btree.  If the btree is corrupt the
> libxfs refcount calls will fail, but on our way out of the function we
> don't make sure to clear all the btree cursor's buffer pointers.  This
> leads to a repair deadlock in xfs/372 when fuzzing ptrs[1] to -1U
> because we forgot to release a buffer.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  repair/rmap.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/repair/rmap.c b/repair/rmap.c
> index 01d6f0f..d51590b 100644
> --- a/repair/rmap.c
> +++ b/repair/rmap.c
> @@ -1359,7 +1359,8 @@ _("Incorrect reference count: saw (%u/%u) len %u nlinks %u; should be (%u/%u) le
>  
>  err:
>  	if (bt_cur)
> -		libxfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
> +		libxfs_btree_del_cursor(bt_cur, error ? XFS_BTREE_ERROR :
> +							XFS_BTREE_NOERROR);

Looks fine.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

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

end of thread, other threads:[~2017-11-09  2:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-08  0:26 [PATCH] xfs_repair: always release btree buffers when refcountbt checks fail Darrick J. Wong
2017-11-09  2:01 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).