]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: add frextents to the lazysbcounters when rtgroups enabled
authorDarrick J. Wong <djwong@kernel.org>
Mon, 5 Aug 2024 17:52:55 +0000 (10:52 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Aug 2024 12:53:49 +0000 (05:53 -0700)
Source kernel commit: 89d25a402bd8d2ec7fa2904640dfae961f148bf9

Make the free rt extent count a part of the lazy sb counters when the
realtime groups feature is enabled.  This is possible because the patch
to recompute frextents from the rtbitmap during log recovery predates
the code adding rtgroup support, hence we know that the value will
always be correct during runtime.

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

index 4f67bc2321cb345d9ca6478c163101eba613d489..9611374c868d72843d8683bf707da73c71f12a9f 100644 (file)
@@ -1165,6 +1165,11 @@ xfs_log_sb(
         * sb counters, despite having a percpu counter. It is always kept
         * consistent with the ondisk rtbitmap by xfs_trans_apply_sb_deltas()
         * and hence we don't need have to update it here.
+        *
+        * sb_frextents was added to the lazy sb counters when the rt groups
+        * feature was introduced.  This counter can go negative due to the way
+        * we handle nearly-lockless reservations, so we must use the _positive
+        * variant here to avoid writing out nonsense frextents.
         */
        if (xfs_has_lazysbcount(mp)) {
                mp->m_sb.sb_icount = percpu_counter_sum_positive(&mp->m_icount);
@@ -1174,6 +1179,9 @@ xfs_log_sb(
                mp->m_sb.sb_fdblocks =
                                percpu_counter_sum_positive(&mp->m_fdblocks);
        }
+       if (xfs_has_rtgroups(mp))
+               mp->m_sb.sb_frextents =
+                               percpu_counter_sum_positive(&mp->m_frextents);
 
        xfs_sb_to_disk(bp->b_addr, &mp->m_sb);
        xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);