aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-09-09 15:37:08 -0400
committerEric Sandeen <sandeen@redhat.com>2019-09-09 15:37:08 -0400
commitac8b6c3808652720abf42e40df27a03f49ee0a4b (patch)
tree2bc365682f897dd8b14cd063771fec91936fa943
parent904a5020dbcb15281c8bdc229cde83da65161984 (diff)
downloadxfsprogs-dev-ac8b6c3808652720abf42e40df27a03f49ee0a4b.tar.gz
xfs_repair: add AG btree rmaps into the filesystem after syncing sb
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> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--repair/phase5.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/repair/phase5.c b/repair/phase5.c
index 2e18cc6947..7f7d3d180a 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);
@@ -2427,14 +2426,6 @@ phase5_func(
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"));