|
|
0bf83d |
From 62c713cb0c7791717c0b2a663ff0cc72842fe6c7 Mon Sep 17 00:00:00 2001
|
|
|
0bf83d |
From: "Darrick J. Wong" <darrick.wong@oracle.com>
|
|
|
0bf83d |
Date: Fri, 20 Nov 2020 17:03:27 -0500
|
|
|
0bf83d |
Subject: [PATCH] xfs_repair: check inode btree block counters in AGI
|
|
|
0bf83d |
|
|
|
0bf83d |
Make sure that both inode btree block counters in the AGI are correct.
|
|
|
0bf83d |
|
|
|
0bf83d |
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
|
|
|
0bf83d |
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
|
|
|
0bf83d |
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
|
|
0bf83d |
---
|
|
|
0bf83d |
|
|
|
0bf83d |
diff --git a/repair/scan.c b/repair/scan.c
|
|
|
0bf83d |
index 5b76212..086a3cd 100644
|
|
|
0bf83d |
--- a/repair/scan.c
|
|
|
0bf83d |
+++ b/repair/scan.c
|
|
|
0bf83d |
@@ -1933,6 +1933,12 @@ _("invalid inode count, inode chunk %d/%u, count %d ninodes %d\n"),
|
|
|
0bf83d |
return suspect;
|
|
|
0bf83d |
}
|
|
|
0bf83d |
|
|
|
0bf83d |
+struct ino_priv {
|
|
|
0bf83d |
+ struct aghdr_cnts *agcnts;
|
|
|
0bf83d |
+ uint32_t ino_blocks;
|
|
|
0bf83d |
+ uint32_t fino_blocks;
|
|
|
0bf83d |
+};
|
|
|
0bf83d |
+
|
|
|
0bf83d |
/*
|
|
|
0bf83d |
* this one walks the inode btrees sucking the info there into
|
|
|
0bf83d |
* the incore avl tree. We try and rescue corrupted btree records
|
|
|
0bf83d |
@@ -1961,7 +1967,8 @@ scan_inobt(
|
|
|
0bf83d |
void *priv,
|
|
|
0bf83d |
const struct xfs_buf_ops *ops)
|
|
|
0bf83d |
{
|
|
|
0bf83d |
- struct aghdr_cnts *agcnts = priv;
|
|
|
0bf83d |
+ struct ino_priv *ipriv = priv;
|
|
|
0bf83d |
+ struct aghdr_cnts *agcnts = ipriv->agcnts;
|
|
|
0bf83d |
char *name;
|
|
|
0bf83d |
int i;
|
|
|
0bf83d |
int numrecs;
|
|
|
0bf83d |
@@ -1977,10 +1984,12 @@ scan_inobt(
|
|
|
0bf83d |
case XFS_FIBT_MAGIC:
|
|
|
0bf83d |
case XFS_FIBT_CRC_MAGIC:
|
|
|
0bf83d |
name = "fino";
|
|
|
0bf83d |
+ ipriv->fino_blocks++;
|
|
|
0bf83d |
break;
|
|
|
0bf83d |
case XFS_IBT_MAGIC:
|
|
|
0bf83d |
case XFS_IBT_CRC_MAGIC:
|
|
|
0bf83d |
name = "ino";
|
|
|
0bf83d |
+ ipriv->ino_blocks++;
|
|
|
0bf83d |
break;
|
|
|
0bf83d |
default:
|
|
|
0bf83d |
name = "(unknown)";
|
|
|
0bf83d |
@@ -2320,6 +2329,9 @@ validate_agi(
|
|
|
0bf83d |
xfs_agnumber_t agno,
|
|
|
0bf83d |
struct aghdr_cnts *agcnts)
|
|
|
0bf83d |
{
|
|
|
0bf83d |
+ struct ino_priv priv = {
|
|
|
0bf83d |
+ .agcnts = agcnts,
|
|
|
0bf83d |
+ };
|
|
|
0bf83d |
xfs_agblock_t bno;
|
|
|
0bf83d |
int i;
|
|
|
0bf83d |
uint32_t magic;
|
|
|
0bf83d |
@@ -2329,7 +2341,7 @@ validate_agi(
|
|
|
0bf83d |
magic = xfs_sb_version_hascrc(&mp->m_sb) ? XFS_IBT_CRC_MAGIC
|
|
|
0bf83d |
: XFS_IBT_MAGIC;
|
|
|
0bf83d |
scan_sbtree(bno, be32_to_cpu(agi->agi_level),
|
|
|
0bf83d |
- agno, 0, scan_inobt, 1, magic, agcnts,
|
|
|
0bf83d |
+ agno, 0, scan_inobt, 1, magic, &priv,
|
|
|
0bf83d |
&xfs_inobt_buf_ops);
|
|
|
0bf83d |
} else {
|
|
|
0bf83d |
do_warn(_("bad agbno %u for inobt root, agno %d\n"),
|
|
|
0bf83d |
@@ -2342,7 +2354,7 @@ validate_agi(
|
|
|
0bf83d |
magic = xfs_sb_version_hascrc(&mp->m_sb) ?
|
|
|
0bf83d |
XFS_FIBT_CRC_MAGIC : XFS_FIBT_MAGIC;
|
|
|
0bf83d |
scan_sbtree(bno, be32_to_cpu(agi->agi_free_level),
|
|
|
0bf83d |
- agno, 0, scan_inobt, 1, magic, agcnts,
|
|
|
0bf83d |
+ agno, 0, scan_inobt, 1, magic, &priv,
|
|
|
0bf83d |
&xfs_inobt_buf_ops);
|
|
|
0bf83d |
} else {
|
|
|
0bf83d |
do_warn(_("bad agbno %u for finobt root, agno %d\n"),
|
|
|
0bf83d |
@@ -2350,6 +2362,17 @@ validate_agi(
|
|
|
0bf83d |
}
|
|
|
0bf83d |
}
|
|
|
0bf83d |
|
|
|
0bf83d |
+ if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) {
|
|
|
0bf83d |
+ if (be32_to_cpu(agi->agi_iblocks) != priv.ino_blocks)
|
|
|
0bf83d |
+ do_warn(_("bad inobt block count %u, saw %u\n"),
|
|
|
0bf83d |
+ be32_to_cpu(agi->agi_iblocks),
|
|
|
0bf83d |
+ priv.ino_blocks);
|
|
|
0bf83d |
+ if (be32_to_cpu(agi->agi_fblocks) != priv.fino_blocks)
|
|
|
0bf83d |
+ do_warn(_("bad finobt block count %u, saw %u\n"),
|
|
|
0bf83d |
+ be32_to_cpu(agi->agi_fblocks),
|
|
|
0bf83d |
+ priv.fino_blocks);
|
|
|
0bf83d |
+ }
|
|
|
0bf83d |
+
|
|
|
0bf83d |
if (be32_to_cpu(agi->agi_count) != agcnts->agicount) {
|
|
|
0bf83d |
do_warn(_("agi_count %u, counted %u in ag %u\n"),
|
|
|
0bf83d |
be32_to_cpu(agi->agi_count), agcnts->agicount, agno);
|