From 85ed3bc340d1f494deb37c09c8b1b3a09ad30b8c Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Fri, 31 Jul 2015 09:18:22 +1000 Subject: [PATCH] repair: use ir_count for filesystems with sparse inode support Repair currently assumes each inobt record covers 64 inodes and uses this value to validate inode counts in the AGI headers and superblock. This is not always the case with sparse inode support. Update scan_inobt() to check for sparse inode support and use the new ir_count field for inode accounting. ir_count contains the total number of inodes tracked by the record. Signed-off-by: Brian Foster Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- repair/scan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/repair/scan.c b/repair/scan.c index e1825ed22..4069f230e 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -1244,7 +1244,16 @@ _("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"), if (magic == XFS_IBT_MAGIC || magic == XFS_IBT_CRC_MAGIC) { - agcnts->agicount += XFS_INODES_PER_CHUNK; + int icount = XFS_INODES_PER_CHUNK; + + /* + * ir_count holds the inode count for all + * records on fs' with sparse inode support + */ + if (xfs_sb_version_hassparseinodes(&mp->m_sb)) + icount = rp[i].ir_u.sp.ir_count; + + agcnts->agicount += icount; agcnts->agifreecount += freecount; agcnts->ifreecount += freecount; -- 2.47.2