From: Brian Foster Date: Thu, 30 Jul 2015 23:18:22 +0000 (+1000) Subject: repair: use ir_count for filesystems with sparse inode support X-Git-Tag: v4.2.0-rc1~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=85ed3bc340d1f494deb37c09c8b1b3a09ad30b8c;p=thirdparty%2Fxfsprogs-dev.git 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 --- 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;