]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: implement busy extent tracking for rtgroups
authorDarrick J. Wong <djwong@kernel.org>
Mon, 25 Nov 2024 21:14:26 +0000 (13:14 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:31 +0000 (18:01 -0800)
Source kernel commit: 7e85fc2394115db56be678b617ed646563926581

For rtgroups filesystems, track newly freed (rt) space through the log
until the rt EFIs have been committed to disk.  This way we ensure that
space cannot be reused until all traces of the old owner are gone.

As a fringe benefit, we now support -o discard on the realtime device.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_rtbitmap.c
libxfs/xfs_rtgroup.h

index e304f07189d3c9992bcf895ce29720428c305f74..b439fb3c20709f4fc437c66a31bea3223a66d94a 100644 (file)
@@ -1116,6 +1116,7 @@ xfs_rtfree_blocks(
 {
        struct xfs_mount        *mp = tp->t_mountp;
        xfs_extlen_t            mod;
+       int                     error;
 
        ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN);
 
@@ -1131,8 +1132,16 @@ xfs_rtfree_blocks(
                return -EIO;
        }
 
-       return xfs_rtfree_extent(tp, rtg, xfs_rtb_to_rtx(mp, rtbno),
+       error = xfs_rtfree_extent(tp, rtg, xfs_rtb_to_rtx(mp, rtbno),
                        xfs_extlen_to_rtxlen(mp, rtlen));
+       if (error)
+               return error;
+
+       if (xfs_has_rtgroups(mp))
+               xfs_extent_busy_insert(tp, rtg_group(rtg),
+                               xfs_rtb_to_rgbno(mp, rtbno), rtlen, 0);
+
+       return 0;
 }
 
 /* Find all the free records within a given range. */
index 1e51dc62d1143ec82b0107382c95a49cdd903dfc..7e7e491ff06fa5bbe0dbbe8c437e23e866b1077d 100644 (file)
@@ -155,6 +155,19 @@ xfs_rtbno_is_group_start(
        return (rtbno & mp->m_groups[XG_TYPE_RTG].blkmask) == 0;
 }
 
+/* Convert an rtgroups rt extent number into an rgbno. */
+static inline xfs_rgblock_t
+xfs_rtx_to_rgbno(
+       struct xfs_rtgroup      *rtg,
+       xfs_rtxnum_t            rtx)
+{
+       struct xfs_mount        *mp = rtg_mount(rtg);
+
+       if (likely(mp->m_rtxblklog >= 0))
+               return rtx << mp->m_rtxblklog;
+       return rtx * mp->m_sb.sb_rextsize;
+}
+
 static inline xfs_daddr_t
 xfs_rtb_to_daddr(
        struct xfs_mount        *mp,