Re: [PATCH v3 1/2] xfs: fix error returns in CoW fork repair

From: Carlos Maiolino

Date: Thu May 28 2026 - 04:18:42 EST


On Wed, May 27, 2026 at 09:44:42PM -0700, Darrick J. Wong wrote:
> On Wed, May 27, 2026 at 12:31:33PM +0800, Yingjie Gao wrote:
> > xrep_cow_find_bad() returns success after the cleanup labels even if
> > AG setup, btree queries, or bitmap updates failed. This can make
> > repair continue with an incomplete bad-file-offset bitmap instead of
> > stopping at the original error.
> >
> > The force-rebuild path has a related cleanup problem. If
> > xrep_cow_mark_file_range() fails, the function returns directly and
> > skips the scrub AG context and perag cleanup.
> >
> > Let the force-rebuild path fall through to the existing cleanup code
> > and return the saved error after cleanup.
> >
>
> Cc: <stable@xxxxxxxxxxxxxxx> # v6.8
>
> (please make life easier for Theodorics A and B who are half-assing LTS
> QA these days)

I can add this at commit time

>
> > Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
> > Signed-off-by: Yingjie Gao <gaoyingjie@xxxxxxxxxxxxx>
> > ---
> > fs/xfs/scrub/cow_repair.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> > index bffc4666ce60..a6ff09ace43d 100644
> > --- a/fs/xfs/scrub/cow_repair.c
> > +++ b/fs/xfs/scrub/cow_repair.c
> > @@ -300,18 +300,15 @@ xrep_cow_find_bad(
> > * on the debugging knob, replace everything in the CoW fork.
> > */
> > if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
> > - XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> > + XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
> > error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> > xc->irec.br_blockcount);
> > - if (error)
> > - return error;
>
> I personally would have stuck with the v1 logic of turning that into a
> "goto out_sa" but either way is correct.
>
> With the cc tag added,
> Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
>
> --D
>
>
> > - }
> >
> > out_sa:
> > xchk_ag_free(sc, &sc->sa);
> > out_pag:
> > xfs_perag_put(pag);
> > - return 0;
> > + return error;
> > }
> >
> > /*
> > --
> > 2.20.1
> >
> >
>