From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 09/12] xfs: check record domain when accessing refcount records
Date: Thu, 27 Oct 2022 14:33:45 -0700 [thread overview]
Message-ID: <Y1r5OdnXJQ461gAY@magnolia> (raw)
In-Reply-To: <20221027211531.GW3600936@dread.disaster.area>
On Fri, Oct 28, 2022 at 08:15:31AM +1100, Dave Chinner wrote:
> On Thu, Oct 27, 2022 at 10:14:53AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Now that we've separated the startblock and CoW/shared extent domain in
> > the incore refcount record structure, check the domain whenever we
> > retrieve a record to ensure that it's still in the domain that we want.
> > Depending on the circumstances, a change in domain either means we're
> > done processing or that we've found a corruption and need to fail out.
> >
> > The refcount check in xchk_xref_is_cow_staging is redundant since
> > _get_rec has done that for a long time now, so we can get rid of it.
> >
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> > fs/xfs/libxfs/xfs_refcount.c | 53 ++++++++++++++++++++++++++++++++----------
> > fs/xfs/scrub/refcount.c | 4 ++-
> > 2 files changed, 43 insertions(+), 14 deletions(-)
> >
> >
> > diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> > index 3b1cb0578770..608a122eef16 100644
> > --- a/fs/xfs/libxfs/xfs_refcount.c
> > +++ b/fs/xfs/libxfs/xfs_refcount.c
> > @@ -386,6 +386,8 @@ xfs_refcount_split_extent(
> > goto out_error;
> > }
> >
> > + if (rcext.rc_domain != domain)
> > + return 0;
> > if (rcext.rc_startblock == agbno || xfs_refc_next(&rcext) <= agbno)
> > return 0;
> >
> > @@ -434,6 +436,9 @@ xfs_refcount_merge_center_extents(
> > int error;
> > int found_rec;
> >
> > + ASSERT(left->rc_domain == center->rc_domain);
> > + ASSERT(right->rc_domain == center->rc_domain);
> > +
> > trace_xfs_refcount_merge_center_extents(cur->bc_mp,
> > cur->bc_ag.pag->pag_agno, left, center, right);
>
> Can you move the asserts to after the trace points? That way we if
> need to debug the assert, we'll have a tracepoint with the record
> information that triggered the assert emitted immediately before it
> fires...
Done.
> >
> > @@ -510,6 +515,8 @@ xfs_refcount_merge_left_extent(
> > int error;
> > int found_rec;
> >
> > + ASSERT(left->rc_domain == cleft->rc_domain);
> > +
> > trace_xfs_refcount_merge_left_extent(cur->bc_mp,
> > cur->bc_ag.pag->pag_agno, left, cleft);
> >
> > @@ -571,6 +578,8 @@ xfs_refcount_merge_right_extent(
> > int error;
> > int found_rec;
> >
> > + ASSERT(right->rc_domain == cright->rc_domain);
> > +
> > trace_xfs_refcount_merge_right_extent(cur->bc_mp,
> > cur->bc_ag.pag->pag_agno, cright, right);
> >
> > @@ -654,12 +663,10 @@ xfs_refcount_find_left_extents(
> > goto out_error;
> > }
> >
> > + if (tmp.rc_domain != domain)
> > + return 0;
> > if (xfs_refc_next(&tmp) != agbno)
> > return 0;
> > - if (domain == XFS_REFC_DOMAIN_SHARED && tmp.rc_refcount < 2)
> > - return 0;
> > - if (domain == XFS_REFC_DOMAIN_COW && tmp.rc_refcount > 1)
> > - return 0;
>
> Ah, as these go away, you can ignore my comment about them in the
> previous patches... :)
>
> Otherwise, looks ok.
>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Cool, thanks!
--D
> --
> Dave Chinner
> david@fromorbit.com
next prev parent reply other threads:[~2022-10-27 21:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 17:14 [PATCHSET v2 00/12] xfs: improve runtime refcountbt corruption detection Darrick J. Wong
2022-10-27 17:14 ` [PATCH 01/12] xfs: make sure aglen never goes negative in xfs_refcount_adjust_extents Darrick J. Wong
2022-10-27 20:41 ` Dave Chinner
2022-10-27 17:14 ` [PATCH 02/12] xfs: check deferred refcount op continuation parameters Darrick J. Wong
2022-10-27 20:49 ` Dave Chinner
2022-10-27 21:32 ` Darrick J. Wong
2022-10-27 21:42 ` Darrick J. Wong
2022-10-27 22:24 ` Dave Chinner
2022-10-27 23:25 ` Darrick J. Wong
2022-10-27 21:54 ` [PATCH v2.1 " Darrick J. Wong
2022-10-27 17:14 ` [PATCH 03/12] xfs: move _irec structs to xfs_types.h Darrick J. Wong
2022-10-27 17:14 ` [PATCH 04/12] xfs: refactor refcount record usage in xchk_refcountbt_rec Darrick J. Wong
2022-10-27 17:14 ` [PATCH 05/12] xfs: track cow/shared record domains explicitly in xfs_refcount_irec Darrick J. Wong
2022-10-27 21:03 ` Dave Chinner
2022-10-27 21:10 ` Darrick J. Wong
2022-10-27 17:14 ` [PATCH 06/12] xfs: report refcount domain in tracepoints Darrick J. Wong
2022-10-27 21:05 ` Dave Chinner
2022-10-27 17:14 ` [PATCH 07/12] xfs: refactor domain and refcount checking Darrick J. Wong
2022-10-27 21:07 ` Dave Chinner
2022-10-27 17:14 ` [PATCH 08/12] xfs: remove XFS_FIND_RCEXT_SHARED and _COW Darrick J. Wong
2022-10-27 21:11 ` Dave Chinner
2022-10-27 17:14 ` [PATCH 09/12] xfs: check record domain when accessing refcount records Darrick J. Wong
2022-10-27 21:15 ` Dave Chinner
2022-10-27 21:33 ` Darrick J. Wong [this message]
2022-10-27 17:14 ` [PATCH 10/12] xfs: fix agblocks check in the cow leftover recovery function Darrick J. Wong
2022-10-27 21:22 ` Dave Chinner
2022-10-27 17:15 ` [PATCH 11/12] xfs: fix uninitialized list head in struct xfs_refcount_recovery Darrick J. Wong
2022-10-27 21:24 ` Dave Chinner
2022-10-27 17:15 ` [PATCH 12/12] xfs: rename XFS_REFC_COW_START to _COWFLAG Darrick J. Wong
2022-10-27 21:25 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1r5OdnXJQ461gAY@magnolia \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox