On Tue, Feb 18, 2025 at 09:10:09AM +0100, Christoph Hellwig wrote: > All callers of xrep_reap_metadir_fsblocks need to fix up the metabtree > reservation, otherwise they'd leave the reservations in an incoherent > state. Move the call to xrep_reset_metafile_resv into > xrep_reap_metadir_fsblocks so it always is taken care of, and remove > now superfluous helper functions in the callers. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> Looks good now, Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --D > --- > fs/xfs/scrub/reap.c | 9 ++++++--- > fs/xfs/scrub/rtrefcount_repair.c | 34 ++++++-------------------------- > fs/xfs/scrub/rtrmap_repair.c | 29 +++++---------------------- > 3 files changed, 17 insertions(+), 55 deletions(-) > > diff --git a/fs/xfs/scrub/reap.c b/fs/xfs/scrub/reap.c > index b32fb233cf84..8703897c0a9c 100644 > --- a/fs/xfs/scrub/reap.c > +++ b/fs/xfs/scrub/reap.c > @@ -935,10 +935,13 @@ xrep_reap_metadir_fsblocks( > if (error) > return error; > > - if (xreap_dirty(&rs)) > - return xrep_defer_finish(sc); > + if (xreap_dirty(&rs)) { > + error = xrep_defer_finish(sc); > + if (error) > + return error; > + } > > - return 0; > + return xrep_reset_metafile_resv(sc); > } > > /* > diff --git a/fs/xfs/scrub/rtrefcount_repair.c b/fs/xfs/scrub/rtrefcount_repair.c > index 257cfb24beb4..983362447826 100644 > --- a/fs/xfs/scrub/rtrefcount_repair.c > +++ b/fs/xfs/scrub/rtrefcount_repair.c > @@ -697,32 +697,6 @@ xrep_rtrefc_build_new_tree( > return error; > } > > -/* > - * Now that we've logged the roots of the new btrees, invalidate all of the > - * old blocks and free them. > - */ > -STATIC int > -xrep_rtrefc_remove_old_tree( > - struct xrep_rtrefc *rr) > -{ > - int error; > - > - /* > - * Free all the extents that were allocated to the former rtrefcountbt > - * and aren't cross-linked with something else. > - */ > - error = xrep_reap_metadir_fsblocks(rr->sc, > - &rr->old_rtrefcountbt_blocks); > - if (error) > - return error; > - > - /* > - * Ensure the proper reservation for the rtrefcount inode so that we > - * don't fail to expand the btree. > - */ > - return xrep_reset_metafile_resv(rr->sc); > -} > - > /* Rebuild the rt refcount btree. */ > int > xrep_rtrefcountbt( > @@ -769,8 +743,12 @@ xrep_rtrefcountbt( > if (error) > goto out_bitmap; > > - /* Kill the old tree. */ > - error = xrep_rtrefc_remove_old_tree(rr); > + /* > + * Free all the extents that were allocated to the former rtrefcountbt > + * and aren't cross-linked with something else. > + */ > + error = xrep_reap_metadir_fsblocks(rr->sc, > + &rr->old_rtrefcountbt_blocks); > if (error) > goto out_bitmap; > > diff --git a/fs/xfs/scrub/rtrmap_repair.c b/fs/xfs/scrub/rtrmap_repair.c > index f2fdd7a9fc24..fc2592c53af5 100644 > --- a/fs/xfs/scrub/rtrmap_repair.c > +++ b/fs/xfs/scrub/rtrmap_repair.c > @@ -810,28 +810,6 @@ xrep_rtrmap_build_new_tree( > > /* Reaping the old btree. */ > > -/* Reap the old rtrmapbt blocks. */ > -STATIC int > -xrep_rtrmap_remove_old_tree( > - struct xrep_rtrmap *rr) > -{ > - int error; > - > - /* > - * Free all the extents that were allocated to the former rtrmapbt and > - * aren't cross-linked with something else. > - */ > - error = xrep_reap_metadir_fsblocks(rr->sc, &rr->old_rtrmapbt_blocks); > - if (error) > - return error; > - > - /* > - * Ensure the proper reservation for the rtrmap inode so that we don't > - * fail to expand the new btree. > - */ > - return xrep_reset_metafile_resv(rr->sc); > -} > - > static inline bool > xrep_rtrmapbt_want_live_update( > struct xchk_iscan *iscan, > @@ -995,8 +973,11 @@ xrep_rtrmapbt( > if (error) > goto out_records; > > - /* Kill the old tree. */ > - error = xrep_rtrmap_remove_old_tree(rr); > + /* > + * Free all the extents that were allocated to the former rtrmapbt and > + * aren't cross-linked with something else. > + */ > + error = xrep_reap_metadir_fsblocks(rr->sc, &rr->old_rtrmapbt_blocks); > if (error) > goto out_records; > > -- > 2.45.2 > >