From: Christoph Hellwig <hch@lst.de>
To: Andrey Albershteyn <aalbersh@kernel.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
Carlos Maiolino <cmaiolino@redhat.com>,
linux-xfs@vger.kernel.org
Subject: [PATCH 3/4] repair: factor out a process_dinode_metafile helper
Date: Wed, 10 Dec 2025 06:54:40 +0100 [thread overview]
Message-ID: <20251210055455.3479288-4-hch@lst.de> (raw)
In-Reply-To: <20251210055455.3479288-1-hch@lst.de>
Split the metafile logic from process_dinode_int into a separate
helper.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
repair/dinode.c | 87 ++++++++++++++++++++++++++-----------------------
1 file changed, 47 insertions(+), 40 deletions(-)
diff --git a/repair/dinode.c b/repair/dinode.c
index 7f987c38d2e4..2e8728594ead 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -2950,6 +2950,52 @@ _("Bad CoW extent size hint %u on inode %" PRIu64 ", "),
}
}
+/*
+ * We always rebuild the metadata directory tree during phase 6, so we mark all
+ * directory blocks and other metadata files whose contents we don't want to
+ * save to be zapped.
+ *
+ * Currently, there are no metadata files that use xattrs, so we always drop the
+ * xattr blocks of metadata files. Parent pointers will be rebuilt during
+ * phase 6.
+ */
+static bool
+process_dinode_metafile(
+ struct xfs_mount *mp,
+ xfs_agnumber_t agno,
+ xfs_agino_t agino,
+ xfs_ino_t lino,
+ enum xr_ino_type type)
+{
+ struct ino_tree_node *irec = find_inode_rec(mp, agno, agino);
+ int off = get_inode_offset(mp, lino, irec);
+
+ set_inode_is_meta(irec, off);
+
+ switch (type) {
+ case XR_INO_RTBITMAP:
+ case XR_INO_RTSUM:
+ /*
+ * RT bitmap and summary files are always recreated when
+ * rtgroups are enabled. For older filesystems, they exist at
+ * fixed locations and cannot be zapped.
+ */
+ if (xfs_has_rtgroups(mp))
+ return true;
+ return false;
+ case XR_INO_UQUOTA:
+ case XR_INO_GQUOTA:
+ case XR_INO_PQUOTA:
+ /*
+ * Quota checking and repair doesn't happen until phase7, so
+ * preserve quota inodes and their contents for later.
+ */
+ return false;
+ default:
+ return true;
+ }
+}
+
/*
* returns 0 if the inode is ok, 1 if the inode is corrupt
* check_dups can be set to 1 *only* when called by the
@@ -3565,48 +3611,9 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
/* Does this inode think it was metadata? */
if (dino->di_version >= 3 &&
(dino->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA))) {
- struct ino_tree_node *irec;
- int off;
-
- irec = find_inode_rec(mp, agno, ino);
- off = get_inode_offset(mp, lino, irec);
- set_inode_is_meta(irec, off);
is_meta = true;
-
- /*
- * We always rebuild the metadata directory tree during phase
- * 6, so we use this flag to get all the directory blocks
- * marked as free, and any other metadata files whose contents
- * we don't want to save.
- *
- * Currently, there are no metadata files that use xattrs, so
- * we always drop the xattr blocks of metadata files. Parent
- * pointers will be rebuilt during phase 6.
- */
- switch (type) {
- case XR_INO_RTBITMAP:
- case XR_INO_RTSUM:
- /*
- * rt bitmap and summary files are always recreated
- * when rtgroups are enabled. For older filesystems,
- * they exist at fixed locations and cannot be zapped.
- */
- if (xfs_has_rtgroups(mp))
- zap_metadata = true;
- break;
- case XR_INO_UQUOTA:
- case XR_INO_GQUOTA:
- case XR_INO_PQUOTA:
- /*
- * Quota checking and repair doesn't happen until
- * phase7, so preserve quota inodes and their contents
- * for later.
- */
- break;
- default:
+ if (process_dinode_metafile(mp, agno, ino, lino, type))
zap_metadata = true;
- break;
- }
}
/*
--
2.47.3
next prev parent reply other threads:[~2025-12-10 5:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 5:54 repair tidyups for metadir handling v3 Christoph Hellwig
2025-12-10 5:54 ` [PATCH 1/4] repair: add a enum for the XR_INO_* values Christoph Hellwig
2025-12-10 5:54 ` [PATCH 2/4] repair: add canonical names for the XR_INO_ constants Christoph Hellwig
2025-12-10 5:54 ` Christoph Hellwig [this message]
2025-12-10 5:54 ` [PATCH 4/4] repair: enhance process_dinode_metafile Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2025-12-08 7:11 repair tidyups for metadir handling v2 Christoph Hellwig
2025-12-08 7:11 ` [PATCH 3/4] repair: factor out a process_dinode_metafile helper Christoph Hellwig
2025-11-28 6:36 repair tidyups for metadir handling Christoph Hellwig
2025-11-28 6:37 ` [PATCH 3/4] repair: factor out a process_dinode_metafile helper Christoph Hellwig
2025-11-28 8:05 ` Carlos Maiolino
2025-12-01 22:47 ` Darrick J. Wong
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=20251210055455.3479288-4-hch@lst.de \
--to=hch@lst.de \
--cc=aalbersh@kernel.org \
--cc=cmaiolino@redhat.com \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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