linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 10/10] xfs_repair: add AG btree rmaps into the filesystem after syncing sb
Date: Tue, 03 Sep 2019 21:38:12 -0700	[thread overview]
Message-ID: <156757189224.1838441.6843620202811391667.stgit@magnolia> (raw)
In-Reply-To: <156757182283.1838441.193482978701233436.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

In rmap_store_ag_btree_rec(), we try to reserve 16 blocks to handle
adding all the AG btree rmaps to the rmap record.  Unfortunately, at
that point in phase5 we haven't yet reinitialied sb_fdblocks, so
reserving blocks can fail if repair reconstructed the primary sb from a
secondary sb.  Even if the function succeeds, this still leads to
incorrect fdblocks because phase 5 resets sb_fdblocks after running the
rmap transactions.

To avoid all this, move the rmap_store_ag_btree_rec call to after the sb
has been reset.  xfs/350 was helpful in finding cases where xfs_repair
errored out while repairing the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/phase5.c |   24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)


diff --git a/repair/phase5.c b/repair/phase5.c
index 2e18cc69..7f7d3d18 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -2233,7 +2233,6 @@ phase5_func(
 #endif
 	xfs_agblock_t	num_extents;
 	struct agi_stat	agi_stat = {0,};
-	int		error;
 
 	if (verbose)
 		do_log(_("        - agno = %d\n"), agno);
@@ -2426,14 +2425,6 @@ phase5_func(
 			finish_cursor(&fino_btree_curs);
 		finish_cursor(&bcnt_btree_curs);
 
-		/*
-		 * Put the per-AG btree rmap data into the rmapbt
-		 */
-		error = rmap_store_ag_btree_rec(mp, agno);
-		if (error)
-			do_error(
-_("unable to add AG %u reverse-mapping data to btree.\n"), agno);
-
 		/*
 		 * release the incore per-AG bno/bcnt trees so
 		 * the extent nodes can be recycled
@@ -2561,6 +2552,21 @@ phase5(xfs_mount_t *mp)
 	 */
 	sync_sb(mp);
 
+	/*
+	 * Put the per-AG btree rmap data into the rmapbt now that we've reset
+	 * the superblock counters.
+	 */
+	for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
+		error = rmap_store_ag_btree_rec(mp, agno);
+		if (error)
+			do_error(
+_("unable to add AG %u reverse-mapping data to btree.\n"), agno);
+	}
+
+	/*
+	 * Put blocks that were unnecessarily reserved for btree
+	 * reconstruction back into the filesystem free space data.
+	 */
 	error = inject_lost_blocks(mp, lost_fsb);
 	if (error)
 		do_error(_("Unable to reinsert lost blocks into filesystem.\n"));


  parent reply	other threads:[~2019-09-04  4:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04  4:37 [PATCH v2 00/10] xfsprogs-5.3: various fixes Darrick J. Wong
2019-09-04  4:37 ` [PATCH 01/10] man: document the new v5 fs geometry ioctl structures Darrick J. Wong
2019-09-09 18:24   ` Eric Sandeen
2019-09-04  4:37 ` [PATCH 02/10] man: document new fs summary counter scrub command Darrick J. Wong
2019-09-09 18:25   ` Eric Sandeen
2019-09-04  4:37 ` [PATCH 03/10] man: document the new allocation group geometry ioctl Darrick J. Wong
2019-09-09 18:51   ` Eric Sandeen
2019-09-04  4:37 ` [PATCH 04/10] man: document the new health reporting fields in various ioctls Darrick J. Wong
2019-09-09 19:19   ` Eric Sandeen
2019-09-16 15:17     ` Darrick J. Wong
2019-09-04  4:37 ` [PATCH 05/10] xfs_db: remove db/convert.h Darrick J. Wong
2019-09-09 19:24   ` Eric Sandeen
2019-09-04  4:37 ` [PATCH 06/10] xfs_db: add a function to compute btree geometry Darrick J. Wong
2019-09-04  4:37 ` [PATCH 07/10] xfs_db: use precomputed inode geometry values Darrick J. Wong
2019-09-04  4:37 ` [PATCH 08/10] xfs_repair: " Darrick J. Wong
2019-09-04  4:38 ` [PATCH 09/10] xfs_repair: reduce the amount of "clearing reflink flag" messages Darrick J. Wong
2019-09-04  4:38 ` Darrick J. Wong [this message]
2019-09-09 19:28   ` [PATCH 10/10] xfs_repair: add AG btree rmaps into the filesystem after syncing sb Eric Sandeen

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=156757189224.1838441.6843620202811391667.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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;
as well as URLs for NNTP newsgroup(s).