public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 15/28] repair: handle sparse format inobt record freecount correctly
Date: Tue,  2 Jun 2015 14:41:48 -0400	[thread overview]
Message-ID: <1433270521-62026-16-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1433270521-62026-1-git-send-email-bfoster@redhat.com>

The sparse inode chunk feature introduces a new inobt record format that
converts ir_freecount from 4 bytes to 1 byte. ir_freecount references
throughout repair currently assume the 'full' format and endian-convert
from the 32-bit value.

Update the xfs_repair inobt scan and tree rebuild codepaths to use the
correct record format for ir_freecount when sparse inodes is enabled.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 repair/phase5.c |  6 +++++-
 repair/scan.c   | 37 +++++++++++++++++++++++++------------
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/repair/phase5.c b/repair/phase5.c
index d01e72b..04bf049 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -1240,7 +1240,11 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
 				inocnt += is_inode_free(ino_rec, k);
 			}
 
-			bt_rec[j].ir_u.f.ir_freecount = cpu_to_be32(inocnt);
+			if (xfs_sb_version_hassparseinodes(&mp->m_sb))
+				bt_rec[j].ir_u.sp.ir_freecount = inocnt;
+			else
+				bt_rec[j].ir_u.f.ir_freecount =
+							cpu_to_be32(inocnt);
 			freecount += inocnt;
 			count += XFS_INODES_PER_CHUNK;
 
diff --git a/repair/scan.c b/repair/scan.c
index e64d0e5..f42459c 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -751,11 +751,16 @@ scan_single_ino_chunk(
 	int			off;
 	int			state;
 	ino_tree_node_t		*ino_rec, *first_rec, *last_rec;
+	int			freecount;
 
 	ino = be32_to_cpu(rp->ir_startino);
 	off = XFS_AGINO_TO_OFFSET(mp, ino);
 	agbno = XFS_AGINO_TO_AGBNO(mp, ino);
 	lino = XFS_AGINO_TO_INO(mp, agno, ino);
+	if (xfs_sb_version_hassparseinodes(&mp->m_sb))
+		freecount = rp->ir_u.sp.ir_freecount;
+	else
+		freecount = be32_to_cpu(rp->ir_u.f.ir_freecount);
 
 	/*
 	 * on multi-block block chunks, all chunks start
@@ -890,10 +895,10 @@ _("inode rec for ino %" PRIu64 " (%d/%d) overlaps existing rec (start %d/%d)\n")
 		}
 	}
 
-	if (nfree != be32_to_cpu(rp->ir_u.f.ir_freecount)) {
-		do_warn(_("ir_freecount/free mismatch, inode "
-			"chunk %d/%u, freecount %d nfree %d\n"),
-			agno, ino, be32_to_cpu(rp->ir_u.f.ir_freecount), nfree);
+	if (nfree != freecount) {
+		do_warn(
+_("ir_freecount/free mismatch, inode chunk %d/%u, freecount %d nfree %d\n"),
+			agno, ino, freecount, nfree);
 	}
 
 	return suspect;
@@ -913,11 +918,16 @@ scan_single_finobt_chunk(
 	int			off;
 	int			state;
 	ino_tree_node_t		*first_rec, *last_rec, *ino_rec;
+	int			freecount;
 
 	ino = be32_to_cpu(rp->ir_startino);
 	off = XFS_AGINO_TO_OFFSET(mp, ino);
 	agbno = XFS_AGINO_TO_AGBNO(mp, ino);
 	lino = XFS_AGINO_TO_INO(mp, agno, ino);
+	if (xfs_sb_version_hassparseinodes(&mp->m_sb))
+		freecount = rp->ir_u.sp.ir_freecount;
+	else
+		freecount = be32_to_cpu(rp->ir_u.f.ir_freecount);
 
 	/*
 	 * on multi-block block chunks, all chunks start at the beginning of the
@@ -1089,10 +1099,10 @@ check_freecount:
 	 * corruption). Issue a warning and continue the scan. The final btree
 	 * reconstruction will correct this naturally.
 	 */
-	if (nfree != be32_to_cpu(rp->ir_u.f.ir_freecount)) {
+	if (nfree != freecount) {
 		do_warn(
 _("finobt ir_freecount/free mismatch, inode chunk %d/%u, freecount %d nfree %d\n"),
-			agno, ino, be32_to_cpu(rp->ir_u.f.ir_freecount), nfree);
+			agno, ino, freecount, nfree);
 	}
 
 	if (!nfree) {
@@ -1137,6 +1147,7 @@ scan_inobt(
 	xfs_inobt_ptr_t		*pp;
 	xfs_inobt_rec_t		*rp;
 	int			hdr_errors;
+	int			freecount;
 
 	hdr_errors = 0;
 
@@ -1210,14 +1221,17 @@ _("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
 		 * the block.  skip processing of bogus records.
 		 */
 		for (i = 0; i < numrecs; i++) {
+			if (xfs_sb_version_hassparseinodes(&mp->m_sb))
+				freecount = rp[i].ir_u.sp.ir_freecount;
+			else
+				freecount = be32_to_cpu(rp[i].ir_u.f.ir_freecount);
+
 			if (magic == XFS_IBT_MAGIC ||
 			    magic == XFS_IBT_CRC_MAGIC) {
 				agcnts->agicount += XFS_INODES_PER_CHUNK;
 				agcnts->icount += XFS_INODES_PER_CHUNK;
-				agcnts->agifreecount +=
-					be32_to_cpu(rp[i].ir_u.f.ir_freecount);
-				agcnts->ifreecount +=
-					be32_to_cpu(rp[i].ir_u.f.ir_freecount);
+				agcnts->agifreecount += freecount;
+				agcnts->ifreecount += freecount;
 
 				suspect = scan_single_ino_chunk(agno, &rp[i],
 						suspect);
@@ -1227,8 +1241,7 @@ _("inode btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
 				 * so only the free inode count is expected to be
 				 * consistent with the agi
 				 */
-				agcnts->fibtfreecount +=
-					be32_to_cpu(rp[i].ir_u.f.ir_freecount);
+				agcnts->fibtfreecount += freecount;
 
 				suspect = scan_single_finobt_chunk(agno, &rp[i],
 						suspect);
-- 
1.9.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2015-06-02 18:42 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 18:41 [PATCH 00/28] xfsprogs: sparse inode chunks Brian Foster
2015-06-02 18:41 ` [PATCH 01/28] xfs: create individual inode alloc. helper Brian Foster
2015-06-02 18:41 ` [PATCH 02/28] xfs: update free inode record logic to support sparse inode records Brian Foster
2015-06-02 18:41 ` [PATCH 03/28] xfs: support min/max agbno args in block allocator Brian Foster
2015-06-02 18:41 ` [PATCH 04/28] xfs: add sparse inode chunk alignment superblock field Brian Foster
2015-06-02 18:41 ` [PATCH 05/28] xfs: use sparse chunk alignment for min. inode allocation requirement Brian Foster
2015-06-02 18:41 ` [PATCH 06/28] xfs: sparse inode chunks feature helpers and mount requirements Brian Foster
2015-06-02 18:41 ` [PATCH 07/28] xfs: add fs geometry bit for sparse inode chunks Brian Foster
2015-06-02 18:41 ` [PATCH 08/28] xfs: introduce inode record hole mask " Brian Foster
2015-06-02 18:41 ` [PATCH 09/28] xfs: pass inode count through ordered icreate log item Brian Foster
2015-06-02 18:41 ` [PATCH 10/28] xfs: enable sparse inode chunks for v5 superblocks Brian Foster
2015-06-02 18:41 ` [PATCH 11/28] mkfs: sparse inode chunk support Brian Foster
2015-06-02 18:41 ` [PATCH 12/28] db: support sparse inode chunk inobt record and sb fields Brian Foster
2015-06-02 18:41 ` [PATCH 13/28] db: show sparse inodes feature state in version command output Brian Foster
2015-06-02 18:41 ` [PATCH 14/28] growfs: display sparse inode status from xfs_info Brian Foster
2015-06-02 18:41 ` Brian Foster [this message]
2015-06-05  0:53   ` [PATCH 15/28] repair: handle sparse format inobt record freecount correctly Dave Chinner
2015-06-02 18:41 ` [PATCH 16/28] repair: remove duplicate field from aghdr_cnts Brian Foster
2015-06-02 18:41 ` [PATCH 17/28] repair: use ir_count for filesystems with sparse inode support Brian Foster
2015-06-02 18:41 ` [PATCH 18/28] repair: scan and track sparse inode chunks correctly Brian Foster
2015-06-05  0:56   ` Dave Chinner
2015-06-02 18:41 ` [PATCH 19/28] repair: scan sparse finobt records correctly Brian Foster
2015-06-05  1:03   ` Dave Chinner
2015-06-05 16:52     ` Brian Foster
2015-06-02 18:41 ` [PATCH 20/28] repair: validate ir_count field for sparse format records Brian Foster
2015-06-02 18:41 ` [PATCH 21/28] repair: process sparse inode records correctly Brian Foster
2015-06-05  1:12   ` Dave Chinner
2015-06-02 18:41 ` [PATCH 22/28] repair: factor out sparse inodes from finobt reconstruction Brian Foster
2015-06-02 18:41 ` [PATCH 23/28] repair: do not account sparse inodes in phase 5 cursor init Brian Foster
2015-06-02 18:41 ` [PATCH 24/28] repair: reconstruct sparse inode records correctly on disk Brian Foster
2015-06-02 18:41 ` [PATCH 25/28] repair: do not prefetch holes in sparse inode chunks Brian Foster
2015-06-02 18:41 ` [PATCH 26/28] repair: handle sparse inode alignment Brian Foster
2015-06-02 18:42 ` [PATCH 27/28] metadump: reorder inode record sanity checks and inode buffer read Brian Foster
2015-06-02 18:42 ` [PATCH 28/28] metadump: support sparse inode records Brian Foster
2015-06-16  0:33 ` [PATCH 00/28] xfsprogs: sparse inode chunks Dave Chinner
2015-06-16  0:39   ` Dave Chinner
2015-06-16 10:55     ` Brian Foster
2015-06-16 20:26       ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433270521-62026-16-git-send-email-bfoster@redhat.com \
    --to=bfoster@redhat.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox