diff mbox

[5/5] xfs: scrub should flag (and repair) unfixed agfls

Message ID 151623406358.4727.1655021837392456302.stgit@magnolia (mailing list archive)
State New, archived
Headers show

Commit Message

Darrick J. Wong Jan. 18, 2018, 12:07 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

If somehow we let a fs with an unfixed agfl slip by, we should flag it
and try to repair it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/agheader.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
index fbd1744..d548656 100644
--- a/fs/xfs/scrub/agheader.c
+++ b/fs/xfs/scrub/agheader.c
@@ -160,8 +160,13 @@  xfs_scrub_superblock(
 	__be16				vernum_mask;
 
 	agno = sc->sm->sm_agno;
-	if (agno == 0)
+	if (agno == 0) {
+		/* If we somehow don't have a fixed agfl, preen... */
+		if (xfs_sb_version_hascrc(&mp->m_sb) &&
+		    !xfs_sb_version_hasfixedagfl(&mp->m_sb))
+			xfs_scrub_block_set_preen(sc, mp->m_sb_bp);
 		return 0;
+	}
 
 	error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
 		  XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
@@ -444,8 +449,13 @@  xfs_repair_superblock(
 
 	/* Don't try to repair AG 0's sb; let xfs_repair deal with it. */
 	agno = sc->sm->sm_agno;
-	if (agno == 0)
+	if (agno == 0) {
+		/* Try to fix the AGFLs if we don't have the feature set */
+		if ((sc->sm->sm_flags & XFS_SCRUB_OFLAG_PREEN) &&
+		    !(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
+			return xfs_agf_fixup_freelist_counts(mp);
 		return -EOPNOTSUPP;
+	}
 
 	error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
 		  XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)),