]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
repair: factor out a process_dinode_metafile helper
authorChristoph Hellwig <hch@lst.de>
Wed, 10 Dec 2025 05:54:40 +0000 (06:54 +0100)
committerAndrey Albershteyn <aalbersh@kernel.org>
Fri, 12 Dec 2025 13:49:20 +0000 (14:49 +0100)
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

index 7f987c38d2e4ab3c8fca3cb0b0183c04614e311d..2e8728594ead7ce7c82d14ae1389c78871a08ea7 100644 (file)
@@ -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;
-               }
        }
 
        /*