On Mon, Feb 08, 2021 at 08:10:21PM -0800, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > Teach the xfs_db version command about the 'needsrepair' flag, which can > be used to force the system administrator to repair the filesystem with > xfs_repair. > > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> > --- Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx> > db/check.c | 5 +++++ > db/sb.c | 13 +++++++++++++ > 2 files changed, 18 insertions(+) > > > diff --git a/db/check.c b/db/check.c > index 33736e33..485e855e 100644 > --- a/db/check.c > +++ b/db/check.c > @@ -3970,6 +3970,11 @@ scan_ag( > dbprintf(_("mkfs not completed successfully\n")); > error++; > } > + if (xfs_sb_version_needsrepair(sb)) { > + if (!sflag) > + dbprintf(_("filesystem needs xfs_repair\n")); > + error++; > + } > set_dbmap(agno, XFS_SB_BLOCK(mp), 1, DBM_SB, agno, XFS_SB_BLOCK(mp)); > if (sb->sb_logstart && XFS_FSB_TO_AGNO(mp, sb->sb_logstart) == agno) > set_dbmap(agno, XFS_FSB_TO_AGBNO(mp, sb->sb_logstart), > diff --git a/db/sb.c b/db/sb.c > index d09f653d..cec7dce9 100644 > --- a/db/sb.c > +++ b/db/sb.c > @@ -379,6 +379,11 @@ uuid_f( > progname); > return 0; > } > + if (xfs_sb_version_needsrepair(&mp->m_sb)) { > + dbprintf(_("%s: filesystem needs xfs_repair\n"), > + progname); > + return 0; > + } > > if (!strcasecmp(argv[1], "generate")) { > platform_uuid_generate(&uu); > @@ -543,6 +548,12 @@ label_f( > return 0; > } > > + if (xfs_sb_version_needsrepair(&mp->m_sb)) { > + dbprintf(_("%s: filesystem needs xfs_repair\n"), > + progname); > + return 0; > + } > + > dbprintf(_("writing all SBs\n")); > for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) > if ((p = do_label(ag, argv[1])) == NULL) { > @@ -691,6 +702,8 @@ version_string( > strcat(s, ",INOBTCNT"); > if (xfs_sb_version_hasbigtime(sbp)) > strcat(s, ",BIGTIME"); > + if (xfs_sb_version_needsrepair(sbp)) > + strcat(s, ",NEEDSREPAIR"); > return s; > } > >