]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: make the RT allocator rtgroup aware
authorChristoph Hellwig <hch@lst.de>
Mon, 5 Aug 2024 20:46:35 +0000 (13:46 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Aug 2024 12:53:49 +0000 (05:53 -0700)
Source kernel commit: 48429f5e97276b8b99a938136db513851bf04ad3

Make the allocator rtgroup aware by either picking a specific group if
there is a hint, or loop over all groups otherwise.  A simple rotor is
provided to pick the placement for initial allocations.

Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_bmap.c
libxfs/xfs_rtbitmap.c

index d02427135e083b513687bb5e026428d01626da5d..b29ddfd556cc5dd0b04f322703a6b5cd7c941bb6 100644 (file)
@@ -3145,8 +3145,17 @@ xfs_bmap_adjacent_valid(
        struct xfs_mount        *mp = ap->ip->i_mount;
 
        if (XFS_IS_REALTIME_INODE(ap->ip) &&
-           (ap->datatype & XFS_ALLOC_USERDATA))
-               return x < mp->m_sb.sb_rblocks;
+           (ap->datatype & XFS_ALLOC_USERDATA)) {
+               if (x >= mp->m_sb.sb_rblocks)
+                       return false;
+               if (!xfs_has_rtgroups(mp))
+                       return true;
+
+               return xfs_rtb_to_rgno(mp, x) == xfs_rtb_to_rgno(mp, y) &&
+                       xfs_rtb_to_rgno(mp, x) < mp->m_sb.sb_rgcount &&
+                       xfs_rtb_to_rtx(mp, x) < mp->m_sb.sb_rgextents;
+
+       }
 
        return XFS_FSB_TO_AGNO(mp, x) == XFS_FSB_TO_AGNO(mp, y) &&
                XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount &&
index e191c232378adf2577e28dfc9a3c59095c2f35b7..655d6a11c6db254459b589e87c372ba8672e2ec2 100644 (file)
@@ -1080,11 +1080,13 @@ xfs_rtfree_extent(
         * Mark more blocks free in the superblock.
         */
        xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, (long)len);
+
        /*
         * If we've now freed all the blocks, reset the file sequence
-        * number to 0.
+        * number to 0 for pre-RTG file systems.
         */
-       if (tp->t_frextents_delta + mp->m_sb.sb_frextents ==
+       if (!xfs_has_rtgroups(mp) &&
+           tp->t_frextents_delta + mp->m_sb.sb_frextents ==
            mp->m_sb.sb_rextents) {
                if (!(rbmip->i_diflags & XFS_DIFLAG_NEWRTBM))
                        rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;