]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
FOLD: xfs: refactor is static metadata inode checks
authorChristoph Hellwig <hch@lst.de>
Fri, 12 Apr 2024 05:58:26 +0000 (07:58 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 12 Apr 2024 05:58:26 +0000 (07:58 +0200)
include/xfs_inode.h
libxfs/libxfs_api_defs.h
repair/rmap.c

index 70b960a46111c26edea389f7a9492528a7dae4ab..0f4ba3284f16fa8b8150bac726d86726efd4693c 100644 (file)
@@ -404,6 +404,30 @@ static inline bool xfs_is_metadir_inode(struct xfs_inode *ip)
        return ip->i_diflags2 & XFS_DIFLAG2_METADIR;
 }
 
+/*
+ * Before metadata directories, the only metadata inodes were the three quota
+ * files, the realtime bitmap, and the realtime summary.
+ */
+static inline bool xfs_is_static_metadata_ino(struct xfs_mount *mp,
+               xfs_ino_t ino)
+{
+       if (xfs_has_metadir(mp))
+               return false;
+       return ino == mp->m_sb.sb_uquotino ||
+               ino == mp->m_sb.sb_gquotino ||
+               ino == mp->m_sb.sb_pquotino ||
+               ino == mp->m_sb.sb_rbmino ||
+               ino == mp->m_sb.sb_rsumino;
+}
+
+static inline bool xfs_is_metadata_inode(struct xfs_inode *ip)
+{
+       /* Any file in the metadata directory tree is a metadata inode. */
+       if (xfs_has_metadir(ip->i_mount))
+               return xfs_is_metadir_inode(ip);
+       return xfs_is_static_metadata_ino(ip->i_mount, ip->i_ino);
+}
+
 extern void    libxfs_trans_inode_alloc_buf (struct xfs_trans *,
                                struct xfs_buf *);
 
index d75df95a799317d7c107814855d2536461242179..21daf7ad6e5d7200edb5da68ba6b3b23eff1e3cd 100644 (file)
 #define xfs_inode_validate_cowextsize  libxfs_inode_validate_cowextsize
 #define xfs_inode_validate_extsize     libxfs_inode_validate_extsize
 
-#define xfs_internal_inum              libxfs_internal_inum
+#define xfs_is_static_metadata_ino     libxfs_is_static_metadata_ino
 
 #define xfs_iread_extents              libxfs_iread_extents
 #define xfs_irele                      libxfs_irele
index 27e56bcaad3295712909efa889a886a58c3a0e4f..222021fc73b7f26033d53a6f58fc1dd35f4a0794 100644 (file)
@@ -1111,7 +1111,7 @@ rmap_shareable(
                return false;
 
        /* Metadata in files are never shareable */
-       if (libxfs_internal_inum(mp, rmap->rm_owner))
+       if (libxfs_is_static_metadata_ino(mp, rmap->rm_owner))
                return false;
 
        /* Metadata and unwritten file blocks are not shareable. */