]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: push transaction join out of xfs_rtbitmap_lock and xfs_rtgroup_lock
authorChristoph Hellwig <hch@lst.de>
Fri, 30 Aug 2024 22:36:59 +0000 (15:36 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 1 Sep 2024 15:58:19 +0000 (08:58 -0700)
To prepare for being able to join an already locked rtbitmap inode to a
transaction split out separate helpers for joining the transaction from
the locking helpers.

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

index 7df74c35d9f900d7f4ebad2608b900b578c2e445..112c7ee2d493cdc002642616481b8d5e31ecd78f 100644 (file)
@@ -5376,7 +5376,8 @@ xfs_bmap_del_extent_real(
                         */
                        if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) {
                                tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED;
-                               xfs_rtbitmap_lock(tp, mp);
+                               xfs_rtbitmap_lock(mp);
+                               xfs_rtbitmap_trans_join(tp);
                        }
                        error = xfs_rtfree_blocks(tp, del->br_startblock,
                                        del->br_blockcount);
index 715d2c54ce029899279f834e7629aac6fd063c59..d7c731aeee12d03811f4ec8c37416a5dfa032408 100644 (file)
@@ -1201,23 +1201,25 @@ xfs_rtsummary_wordcount(
        return XFS_FSB_TO_B(mp, blocks) >> XFS_WORDLOG;
 }
 
-/*
- * Lock both realtime free space metadata inodes for a freespace update.  If a
- * transaction is given, the inodes will be joined to the transaction and the
- * ILOCKs will be released on transaction commit.
- */
+/* Lock both realtime free space metadata inodes for a freespace update. */
 void
 xfs_rtbitmap_lock(
-       struct xfs_trans        *tp,
        struct xfs_mount        *mp)
 {
        xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP);
-       if (tp)
-               xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL);
-
        xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
-       if (tp)
-               xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL);
+}
+
+/*
+ * Join both realtime free space metadata inodes to the transaction.  The
+ * ILOCKs will be released on transaction commit.
+ */
+void
+xfs_rtbitmap_trans_join(
+       struct xfs_trans        *tp)
+{
+       xfs_trans_ijoin(tp, tp->t_mountp->m_rbmip, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, tp->t_mountp->m_rsumip, XFS_ILOCK_EXCL);
 }
 
 /* Unlock both realtime free space metadata inodes after a freespace update. */
index 0d5ab5e2cb6a329eae5a523508c2ab744f2067dc..523d3d3c12c608d0c9d452855b9eb24eb4260704 100644 (file)
@@ -346,8 +346,9 @@ unsigned long long xfs_rtsummary_wordcount(struct xfs_mount *mp,
 int xfs_rtfile_initialize_blocks(struct xfs_inode *ip,
                xfs_fileoff_t offset_fsb, xfs_fileoff_t end_fsb, void *data);
 
-void xfs_rtbitmap_lock(struct xfs_trans *tp, struct xfs_mount *mp);
+void xfs_rtbitmap_lock(struct xfs_mount *mp);
 void xfs_rtbitmap_unlock(struct xfs_mount *mp);
+void xfs_rtbitmap_trans_join(struct xfs_trans *tp);
 
 /* Lock the rt bitmap inode in shared mode */
 #define XFS_RBMLOCK_BITMAP     (1U << 0)
@@ -376,7 +377,8 @@ xfs_rtbitmap_blockcount(struct xfs_mount *mp, xfs_rtbxlen_t rtextents)
 # define xfs_rtbitmap_wordcount(mp, r)                 (0)
 # define xfs_rtsummary_blockcount(mp, l, b)            (0)
 # define xfs_rtsummary_wordcount(mp, l, b)             (0)
-# define xfs_rtbitmap_lock(tp, mp)             do { } while (0)
+# define xfs_rtbitmap_lock(mp)                 do { } while (0)
+# define xfs_rtbitmap_trans_join(tp)           do { } while (0)
 # define xfs_rtbitmap_unlock(mp)               do { } while (0)
 # define xfs_rtbitmap_lock_shared(mp, lf)      do { } while (0)
 # define xfs_rtbitmap_unlock_shared(mp, lf)    do { } while (0)
index 114807cd80bac8ee839607e6825d65b63106b6c0..d290749b0304d3d8fd0f050f715ab319af2b1e39 100644 (file)
@@ -739,7 +739,8 @@ xfs_growfs_rt_bmblock(
                goto out_free;
        nargs.tp = args.tp;
 
-       xfs_rtbitmap_lock(args.tp, mp);
+       xfs_rtbitmap_lock(mp);
+       xfs_rtbitmap_trans_join(args.tp);
 
        /*
         * Update the bitmap inode's size ondisk and incore.  We need to update
@@ -1313,7 +1314,8 @@ retry:
         * Lock out modifications to both the RT bitmap and summary inodes
         */
        if (!rtlocked) {
-               xfs_rtbitmap_lock(ap->tp, mp);
+               xfs_rtbitmap_lock(mp);
+               xfs_rtbitmap_trans_join(ap->tp);
                rtlocked = true;
        }