]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use a separate frextents counter for rt extent reservations
authorDarrick J. Wong <djwong@kernel.org>
Wed, 22 Jun 2022 19:28:52 +0000 (14:28 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 22 Jun 2022 19:28:52 +0000 (14:28 -0500)
Source kernel commit: 2229276c5283264b8c2241c1ed972bbb136cab22

As mentioned in the previous commit, the kernel misuses sb_frextents in
the incore mount to reflect both incore reservations made by running
transactions as well as the actual count of free rt extents on disk.
This results in the superblock being written to the log with an
underestimate of the number of rt extents that are marked free in the
rtbitmap.

Teaching XFS to recompute frextents after log recovery avoids
operational problems in the current mount, but it doesn't solve the
problem of us writing undercounted frextents which are then recovered by
an older kernel that doesn't have that fix.

Create an incore percpu counter to mirror the ondisk frextents.  This
new counter will track transaction reservations and the only time we
will touch the incore super counter (i.e the one that gets logged) is
when those transactions commit updates to the rt bitmap.  This is in
contrast to the lazysbcount counters (e.g. fdblocks), where we know that
log recovery will always fix any incorrect counter that we log.
As a bonus, we only take m_sb_lock at transaction commit time.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_sb.c

index 8781cd806d7f56bd149c8c56f4cd68f31a7c1afd..c9a3e1bfbd6bf84ebb1d62c1bd0284322cacd225 100644 (file)
@@ -912,6 +912,11 @@ xfs_log_sb(
         * reservations that have been taken out percpu counters. If we have an
         * unclean shutdown, this will be corrected by log recovery rebuilding
         * the counters from the AGF block counts.
+        *
+        * Do not update sb_frextents here because it is not part of the lazy
+        * 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.
         */
        if (xfs_has_lazysbcount(mp)) {
                mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount);