xfs
[Top] [All Lists]

[PATCH 17/28] repair: use ir_count for filesystems with sparse inode sup

To: xfs@xxxxxxxxxxx
Subject: [PATCH 17/28] repair: use ir_count for filesystems with sparse inode support
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 2 Jun 2015 14:41:50 -0400
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1433270521-62026-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1433270521-62026-1-git-send-email-bfoster@xxxxxxxxxx>
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@xxxxxxxxxx>
---
 repair/scan.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/repair/scan.c b/repair/scan.c
index 9daa488..8677e41 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -1227,7 +1227,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;
 
-- 
1.9.3

<Prev in Thread] Current Thread [Next in Thread>