]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add some rtgroup inode helpers
authorDarrick J. Wong <djwong@kernel.org>
Mon, 24 Feb 2025 18:21:46 +0000 (10:21 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 25 Feb 2025 17:15:57 +0000 (09:15 -0800)
Source kernel commit: af32541081ed6b6ad49b1ea38b5128cb319841b0

Create some simple helpers to reduce the amount of typing whenever we
access rtgroup inodes.  Conversion was done with this spatch and some
minor reformatting:

@@
expression rtg;
@@

- rtg->rtg_inodes[XFS_RTGI_BITMAP]
+ rtg_bitmap(rtg)

@@
expression rtg;
@@

- rtg->rtg_inodes[XFS_RTGI_SUMMARY]
+ rtg_summary(rtg)

and the CLI command:

$ spatch --sp-file /tmp/moo.cocci --dir fs/xfs/ --use-gitgrep --in-place

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

index b439fb3c20709f4fc437c66a31bea3223a66d94a..689d5844b8bd09ee02c2b826a001a470f51fb47f 100644 (file)
@@ -1050,7 +1050,7 @@ xfs_rtfree_extent(
        xfs_rtxlen_t            len)    /* length of extent freed */
 {
        struct xfs_mount        *mp = tp->t_mountp;
-       struct xfs_inode        *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
+       struct xfs_inode        *rbmip = rtg_bitmap(rtg);
        struct xfs_rtalloc_args args = {
                .mp             = mp,
                .tp             = tp,
index aaaec2a1cef9e51c3649341f4d62e91f3d650518..e422a7bc41a55e3c1c513647c31b147d5ea2ddbd 100644 (file)
@@ -194,10 +194,10 @@ xfs_rtgroup_lock(
                 * Lock both realtime free space metadata inodes for a freespace
                 * update.
                 */
-               xfs_ilock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_EXCL);
-               xfs_ilock(rtg->rtg_inodes[XFS_RTGI_SUMMARY], XFS_ILOCK_EXCL);
+               xfs_ilock(rtg_bitmap(rtg), XFS_ILOCK_EXCL);
+               xfs_ilock(rtg_summary(rtg), XFS_ILOCK_EXCL);
        } else if (rtglock_flags & XFS_RTGLOCK_BITMAP_SHARED) {
-               xfs_ilock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_SHARED);
+               xfs_ilock(rtg_bitmap(rtg), XFS_ILOCK_SHARED);
        }
 }
 
@@ -212,10 +212,10 @@ xfs_rtgroup_unlock(
               !(rtglock_flags & XFS_RTGLOCK_BITMAP));
 
        if (rtglock_flags & XFS_RTGLOCK_BITMAP) {
-               xfs_iunlock(rtg->rtg_inodes[XFS_RTGI_SUMMARY], XFS_ILOCK_EXCL);
-               xfs_iunlock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_EXCL);
+               xfs_iunlock(rtg_summary(rtg), XFS_ILOCK_EXCL);
+               xfs_iunlock(rtg_bitmap(rtg), XFS_ILOCK_EXCL);
        } else if (rtglock_flags & XFS_RTGLOCK_BITMAP_SHARED) {
-               xfs_iunlock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_SHARED);
+               xfs_iunlock(rtg_bitmap(rtg), XFS_ILOCK_SHARED);
        }
 }
 
@@ -233,10 +233,8 @@ xfs_rtgroup_trans_join(
        ASSERT(!(rtglock_flags & XFS_RTGLOCK_BITMAP_SHARED));
 
        if (rtglock_flags & XFS_RTGLOCK_BITMAP) {
-               xfs_trans_ijoin(tp, rtg->rtg_inodes[XFS_RTGI_BITMAP],
-                               XFS_ILOCK_EXCL);
-               xfs_trans_ijoin(tp, rtg->rtg_inodes[XFS_RTGI_SUMMARY],
-                               XFS_ILOCK_EXCL);
+               xfs_trans_ijoin(tp, rtg_bitmap(rtg), XFS_ILOCK_EXCL);
+               xfs_trans_ijoin(tp, rtg_summary(rtg), XFS_ILOCK_EXCL);
        }
 }
 
index 2d7822644efff02be8913e503a4c013c526ca53b..2e145ea2de8007fa892bc79c82634aa6a77ae11d 100644 (file)
@@ -64,6 +64,16 @@ static inline xfs_rgnumber_t rtg_rgno(const struct xfs_rtgroup *rtg)
        return rtg->rtg_group.xg_gno;
 }
 
+static inline struct xfs_inode *rtg_bitmap(const struct xfs_rtgroup *rtg)
+{
+       return rtg->rtg_inodes[XFS_RTGI_BITMAP];
+}
+
+static inline struct xfs_inode *rtg_summary(const struct xfs_rtgroup *rtg)
+{
+       return rtg->rtg_inodes[XFS_RTGI_SUMMARY];
+}
+
 /* Passive rtgroup references */
 static inline struct xfs_rtgroup *
 xfs_rtgroup_get(
index 6dd3a2005b15b35219b4fc073e0b8ee7f5fe6f23..60e5c7d02713d0c1c0ccc6b47fb7255b3a8d844c 100644 (file)
@@ -1057,7 +1057,7 @@ rtfreesp_init(
                if (error)
                        res_failed(error);
 
-               libxfs_trans_ijoin(tp, rtg->rtg_inodes[XFS_RTGI_BITMAP], 0);
+               libxfs_trans_ijoin(tp, rtg_bitmap(rtg), 0);
                error = -libxfs_rtfree_extent(tp, rtg, start_rtx, nr);
                if (error) {
                        fprintf(stderr,