public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: xfs-dev <xfs-dev@sgi.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: review [1 of 3]: lazy superblock counters - fix interaction with per-cpu incore counters
Date: Fri, 20 Apr 2007 09:18:59 +1000	[thread overview]
Message-ID: <20070419231859.GY48531920@melbourne.sgi.com> (raw)


We need to reinitialise the per-cpu superblock counters after
we have corrected them in the new recovery phase (summing hte AGF/AGI
counters.

-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

---
 fs/xfs/xfs_mount.c |   53 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 21 deletions(-)

Index: 2.6.x-xfs-new/fs/xfs/xfs_mount.c
===================================================================
--- 2.6.x-xfs-new.orig/fs/xfs/xfs_mount.c	2007-04-19 13:46:42.536211213 +1000
+++ 2.6.x-xfs-new/fs/xfs/xfs_mount.c	2007-04-19 13:47:41.272642686 +1000
@@ -676,6 +676,10 @@ xfs_initialize_perag_data(xfs_mount_t *m
 	sbp->sb_icount = ialloc;
 	sbp->sb_fdblocks = bfree + bfreelst + btree;
 	XFS_SB_UNLOCK(mp, s);
+
+	/* Fixup the per-cpu counters as well. */
+	xfs_icsb_reinit_counters(mp);
+
 	return 0;
 }
 
@@ -1022,6 +1026,34 @@ xfs_mountfs(
 	}
 
 	/*
+	 * Now the log is mounted, we know if it was an unclean shutdown or
+	 * not. If it was, with the first phase of recovery has completed, we
+	 * have consistent AG blocks on disk. We have not recovered EFIs yet,
+	 * but they are recovered transactionally in the second recovery phase
+	 * later.
+	 *
+	 * Hence we can safely re-initialise incore superblock counters from
+	 * the per-ag data. These may not be correct if the filesystem was not
+	 * cleanly unmounted, so we need to wait for recovery to finish before
+	 * doing this.
+	 *
+	 * If the filesystem was cleanly unmounted, then we can trust the
+	 * values in the superblock to be correct and we don't need to do
+	 * anything here.
+	 *
+	 * If we are currently making the filesystem, the initialisation will
+	 * fail as the perag data is in an undefined state.
+	 */
+
+	if (XFS_SB_VERSION_LAZYSBCOUNT(&mp->m_sb) &&
+	    !XFS_LAST_UNMOUNT_WAS_CLEAN(mp) &&
+	     !mp->m_sb.sb_inprogress) {
+		error = xfs_initialize_perag_data(mp, sbp->sb_agcount);
+		if (error) {
+			goto error2;
+		}
+	}
+	/*
 	 * Get and sanity-check the root inode.
 	 * Save the pointer to it in the mount structure.
 	 */
@@ -1084,27 +1116,6 @@ xfs_mountfs(
 		goto error4;
 	}
 
-	/*
-	 * Now recovery has completed, we can initialise incore
-	 * superblock counters from the per-ag data. These may not
-	 * be correct if the filesystem was not cleanly unmounted,
-	 * so we need to wait for recovery to finish before doing this.
-	 *
-	 * If the filesystem was cleanly unmounted, then we can trust
-	 * the values in the superblock to be correct and we don't need
-	 * to do anything here.
-	 *
-	 * If we are currently making the filesystem, the initialisation
-	 * will fail as the perag data is in an undefined state.
-	 */
-	if (XFS_SB_VERSION_LAZYSBCOUNT(&mp->m_sb) &&
-	    !XFS_LAST_UNMOUNT_WAS_CLEAN(mp) &&
-	     !mp->m_sb.sb_inprogress) {
-		error = xfs_initialize_perag_data(mp, sbp->sb_agcount);
-		if (error) {
-			goto error4;
-		}
-	}
 
 	/*
 	 * Complete the quota initialisation, post-log-replay component.

             reply	other threads:[~2007-04-19 23:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-19 23:18 David Chinner [this message]
2007-04-23 22:00 ` review [1 of 3]: lazy superblock counters - fix interaction with per-cpu incore counters Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070419231859.GY48531920@melbourne.sgi.com \
    --to=dgc@sgi.com \
    --cc=xfs-dev@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox