summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-08-16 11:55:56 -0700
committerDarrick J. Wong <djwong@kernel.org>2022-11-09 19:07:58 -0800
commit9a882bb9171bbd1af395e938754cbe647ec82027 (patch)
tree4ed165430f648600097097dd81ca52be6fa72017 /fs
parentc90cdb7181d56ca4f8d3b7b7c442f7dc339c61d6 (diff)
xfs: add frextents to the lazysbcounters when rtgroups enabled
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_sb.c5
-rw-r--r--fs/xfs/xfs_trans.c18
2 files changed, 20 insertions, 3 deletions
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 4fdc9bfc5c50..5a0e7bf22a12 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -1089,12 +1089,17 @@ 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.
*/
if (xfs_has_lazysbcount(mp)) {
mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount);
mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree);
mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks);
}
+ if (xfs_has_rtgroups(mp))
+ mp->m_sb.sb_frextents = percpu_counter_sum(&mp->m_frextents);
xfs_sb_to_disk(bp->b_addr, &mp->m_sb);
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index a6f46cd9e60c..05e93af190df 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -475,6 +475,8 @@ xfs_trans_mod_sb(
ASSERT(tp->t_rtx_res_used <= tp->t_rtx_res);
}
tp->t_frextents_delta += delta;
+ if (xfs_has_rtgroups(mp))
+ flags &= ~XFS_TRANS_SB_DIRTY;
break;
case XFS_TRANS_SB_RES_FREXTENTS:
/*
@@ -569,8 +571,14 @@ xfs_trans_apply_sb_deltas(
*
* Don't touch m_frextents because it includes incore reservations,
* and those are handled by the unreserve function.
+ *
+ * sb_frextents was added to the lazy sb counters when the rt groups
+ * feature was introduced. This is possible because we know that all
+ * kernels supporting rtgroups will also recompute frextents from the
+ * realtime bitmap.
*/
- if (tp->t_frextents_delta || tp->t_res_frextents_delta) {
+ if ((tp->t_frextents_delta || tp->t_res_frextents_delta) &&
+ !xfs_has_rtgroups(tp->t_mountp)) {
struct xfs_mount *mp = tp->t_mountp;
int64_t rtxdelta;
@@ -684,7 +692,8 @@ xfs_trans_unreserve_and_mod_sb(
if (tp->t_rtx_res > 0)
rtxdelta = tp->t_rtx_res;
if ((tp->t_frextents_delta != 0) &&
- (tp->t_flags & XFS_TRANS_SB_DIRTY))
+ (xfs_has_rtgroups(mp) ||
+ (tp->t_flags & XFS_TRANS_SB_DIRTY)))
rtxdelta += tp->t_frextents_delta;
if (xfs_has_lazysbcount(mp) ||
@@ -723,8 +732,11 @@ xfs_trans_unreserve_and_mod_sb(
* Do not touch sb_frextents here because we are dealing with incore
* reservation. sb_frextents is not part of the lazy sb counters so it
* must be consistent with the ondisk rtbitmap and must never include
- * incore reservations.
+ * incore reservations. sb_frextents was added to the lazy sb counters
+ * when the realtime groups feature was introduced.
*/
+ if (xfs_has_rtgroups(mp))
+ mp->m_sb.sb_frextents += rtxdelta;
mp->m_sb.sb_dblocks += tp->t_dblocks_delta;
mp->m_sb.sb_agcount += tp->t_agcount_delta;
mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta;