]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
repair: use ir_count for filesystems with sparse inode support
authorBrian Foster <bfoster@redhat.com>
Thu, 30 Jul 2015 23:18:22 +0000 (09:18 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 30 Jul 2015 23:18:22 +0000 (09:18 +1000)
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 <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/scan.c

index e1825ed2226b42dcff890f4d08b0a5f182b0f5e4..4069f230e4ed7b152720cedbdfd8902b5d8d8c4a 100644 (file)
@@ -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;