@@ -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)),