summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_log.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2021-01-22 16:48:23 -0800
committerDarrick J. Wong <djwong@kernel.org>2021-01-22 16:54:51 -0800
commitf46e5a174655fd0bdb73008f6a4967d9c706f691 (patch)
tree74836c8661e5b4a22ded30a31c22547a382d73ab /fs/xfs/xfs_log.c
parentb0eb9e1182668b0e9cf81dbf38041cfb8c12887f (diff)
downloadlwn-f46e5a174655fd0bdb73008f6a4967d9c706f691.tar.gz
lwn-f46e5a174655fd0bdb73008f6a4967d9c706f691.zip
xfs: fold sbcount quiesce logging into log covering
xfs_log_sbcount() calls xfs_sync_sb() to sync superblock counters to disk when lazy superblock accounting is enabled. This occurs on unmount, freeze, and read-only (re)mount and ensures the final values are calculated and persisted to disk before each form of quiesce completes. Now that log covering occurs in all of these contexts and uses the same xfs_sync_sb() mechanism to update log state, there is no need to log the superblock separately for any reason. Update the log quiesce path to sync the superblock at least once for any mount where lazy superblock accounting is enabled. If the log is already covered, it will remain in the covered state. Otherwise, the next sync as part of the normal covering sequence will carry the associated superblock update with it. Remove xfs_log_sbcount() now that it is no longer needed. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r--fs/xfs/xfs_log.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index a613f008b95f..58699881c100 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1110,6 +1110,7 @@ xfs_log_cover(
{
struct xlog *log = mp->m_log;
int error = 0;
+ bool need_covered;
ASSERT((xlog_cil_empty(log) && xlog_iclogs_empty(log) &&
!xfs_ail_min_lsn(log->l_ailp)) ||
@@ -1119,6 +1120,21 @@ xfs_log_cover(
return 0;
/*
+ * xfs_log_need_covered() is not idempotent because it progresses the
+ * state machine if the log requires covering. Therefore, we must call
+ * this function once and use the result until we've issued an sb sync.
+ * Do so first to make that abundantly clear.
+ *
+ * Fall into the covering sequence if the log needs covering or the
+ * mount has lazy superblock accounting to sync to disk. The sb sync
+ * used for covering accumulates the in-core counters, so covering
+ * handles this for us.
+ */
+ need_covered = xfs_log_need_covered(mp);
+ if (!need_covered && !xfs_sb_version_haslazysbcount(&mp->m_sb))
+ return 0;
+
+ /*
* To cover the log, commit the superblock twice (at most) in
* independent checkpoints. The first serves as a reference for the
* tail pointer. The sync transaction and AIL push empties the AIL and
@@ -1127,12 +1143,12 @@ xfs_log_cover(
* covering the log. Push the AIL one more time to leave it empty, as
* we found it.
*/
- while (xfs_log_need_covered(mp)) {
+ do {
error = xfs_sync_sb(mp, true);
if (error)
break;
xfs_ail_push_all_sync(mp->m_ail);
- }
+ } while (xfs_log_need_covered(mp));
return error;
}