From: Christoph Hellwig Date: Wed, 10 Dec 2025 05:54:40 +0000 (+0100) Subject: repair: factor out a process_dinode_metafile helper X-Git-Tag: v6.18.0~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a439b4155fd50e9854852ca9e1a853793b686f36;p=xfsprogs-dev.git repair: factor out a process_dinode_metafile helper Split the metafile logic from process_dinode_int into a separate helper. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino Reviewed-by: Darrick J. Wong --- diff --git a/repair/dinode.c b/repair/dinode.c index 7f987c38..2e872859 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; - } } /*