]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xfs: use deferred intent items for reaping crosslinked blocks
authorDarrick J. Wong <djwong@kernel.org>
Mon, 20 Oct 2025 15:51:16 +0000 (11:51 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Oct 2025 14:16:41 +0000 (16:16 +0200)
[ Upstream commit cd32a0c0dcdf634f2e0e71f41c272e19dece6264 ]

When we're removing rmap records for crosslinked blocks, use deferred
intent items so that we can try to free/unmap as many of the old data
structure's blocks as we can in the same transaction as the commit.

Cc: <stable@vger.kernel.org> # v6.6
Fixes: 1c7ce115e52106 ("xfs: reap large AG metadata extents when possible")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[ adjusted xfs_rmap_free_extent() and xfs_refcount_free_cow_extent() ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/scrub/reap.c

index 822f5adf7f7cc97249c206135b040ad2e2bc2ccb..b968f7bc202cfd1bfd7fe67ebfa183b211370b62 100644 (file)
@@ -20,6 +20,7 @@
 #include "xfs_ialloc_btree.h"
 #include "xfs_rmap.h"
 #include "xfs_rmap_btree.h"
+#include "xfs_refcount.h"
 #include "xfs_refcount_btree.h"
 #include "xfs_extent_busy.h"
 #include "xfs_ag.h"
@@ -376,9 +377,21 @@ xreap_agextent_iter(
        if (crosslinked) {
                trace_xreap_dispose_unmap_extent(sc->sa.pag, agbno, *aglenp);
 
-               rs->force_roll = true;
-               return xfs_rmap_free(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno,
-                               *aglenp, rs->oinfo);
+               if (rs->oinfo == &XFS_RMAP_OINFO_COW) {
+                       /*
+                        * If we're unmapping CoW staging extents, remove the
+                        * records from the refcountbt, which will remove the
+                        * rmap record as well.
+                        */
+                       xfs_refcount_free_cow_extent(sc->tp, fsbno, *aglenp);
+                       rs->force_roll = true;
+                       return 0;
+               }
+
+               xfs_rmap_free_extent(sc->tp, sc->sa.pag->pag_agno, agbno,
+                               *aglenp, rs->oinfo->oi_owner);
+               rs->deferred++;
+               return 0;
        }
 
        trace_xreap_dispose_free_extent(sc->sa.pag, agbno, *aglenp);