xfs: fixup the metabtree reservation in xrep_reap_metadir_fsblocks

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@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
This commit is contained in:
Christoph Hellwig 2025-02-15 07:43:02 +01:00
parent a0760cca8e
commit c0bd736d33
3 changed files with 17 additions and 55 deletions

View File

@ -935,10 +935,13 @@ xrep_reap_metadir_fsblocks(
if (error) if (error)
return error; return error;
if (xreap_dirty(&rs)) if (xreap_dirty(&rs)) {
return xrep_defer_finish(sc); error = xrep_defer_finish(sc);
if (error)
return error;
}
return 0; return xrep_reset_metafile_resv(sc);
} }
/* /*

View File

@ -697,32 +697,6 @@ xrep_rtrefc_build_new_tree(
return error; 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. */ /* Rebuild the rt refcount btree. */
int int
xrep_rtrefcountbt( xrep_rtrefcountbt(
@ -769,8 +743,12 @@ xrep_rtrefcountbt(
if (error) if (error)
goto out_bitmap; 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) if (error)
goto out_bitmap; goto out_bitmap;

View File

@ -810,28 +810,6 @@ xrep_rtrmap_build_new_tree(
/* Reaping the old btree. */ /* 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 static inline bool
xrep_rtrmapbt_want_live_update( xrep_rtrmapbt_want_live_update(
struct xchk_iscan *iscan, struct xchk_iscan *iscan,
@ -995,8 +973,11 @@ xrep_rtrmapbt(
if (error) if (error)
goto out_records; 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) if (error)
goto out_records; goto out_records;