From de85211765dfd22f39214597621f356caf70a088 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 12 Apr 2024 06:53:25 +0200 Subject: [PATCH] xfs: refactor is static metadata inode checks Source kernel commit: c1a55c7bacaa75f4b87dbf3678080448879b170e Use a single helper to check for the up to give static metatada inodes. Include the !metadir check in it as metadir file systems never have them set. Remove the duplicate check in xrep_orphanage_can_adopt as it already checks for all metadata inodes directly below. Remove the xfs_internal_inum wrapper as xfs_is_static_metadata_ino is much more descriptive for what it does. Check that an ino is valid before checking it is metadata in all places that do both. Signed-off-by: Christoph Hellwig --- libxfs/xfs_imeta.c | 18 ------------------ libxfs/xfs_imeta.h | 1 - libxfs/xfs_types.c | 17 +++++------------ libxfs/xfs_types.h | 1 - 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/libxfs/xfs_imeta.c b/libxfs/xfs_imeta.c index 11eeb3848..50f8f77c8 100644 --- a/libxfs/xfs_imeta.c +++ b/libxfs/xfs_imeta.c @@ -999,24 +999,6 @@ xfs_imeta_link( return xfs_imeta_sb_link(upd); } -/* Does this inode number refer to a static metadata inode? */ -bool -xfs_is_static_meta_ino( - struct xfs_mount *mp, - xfs_ino_t ino) -{ - const struct xfs_imeta_sbmap *p; - - if (ino == NULLFSINO) - return false; - - for (p = xfs_imeta_sbmaps; p->path; p++) - if (ino == *xfs_imeta_sbmap_to_inop(mp, p)) - return true; - - return false; -} - /* * Ensure that the in-core superblock has all the values that it should. * Caller should pass in an empty transaction to avoid livelocking on btree diff --git a/libxfs/xfs_imeta.h b/libxfs/xfs_imeta.h index 4eadb3352..4e9ae35d2 100644 --- a/libxfs/xfs_imeta.h +++ b/libxfs/xfs_imeta.h @@ -95,7 +95,6 @@ int xfs_imeta_create(struct xfs_imeta_update *upd, umode_t mode, int xfs_imeta_unlink(struct xfs_imeta_update *upd); int xfs_imeta_link(struct xfs_imeta_update *upd); -bool xfs_is_static_meta_ino(struct xfs_mount *mp, xfs_ino_t ino); int xfs_imeta_mount(struct xfs_trans *tp); unsigned int xfs_imeta_create_space_res(struct xfs_mount *mp); diff --git a/libxfs/xfs_types.c b/libxfs/xfs_types.c index 6488cda24..5b2991262 100644 --- a/libxfs/xfs_types.c +++ b/libxfs/xfs_types.c @@ -12,7 +12,7 @@ #include "xfs_bit.h" #include "xfs_mount.h" #include "xfs_ag.h" -#include "xfs_imeta.h" +#include "xfs_inode.h" #include "xfs_rtbitmap.h" #include "xfs_rtgroup.h" @@ -112,15 +112,6 @@ xfs_verify_ino( return xfs_verify_agno_agino(mp, agno, agino); } -/* Is this an internal inode number? */ -inline bool -xfs_internal_inum( - struct xfs_mount *mp, - xfs_ino_t ino) -{ - return xfs_is_static_meta_ino(mp, ino); -} - /* * Verify that a directory entry's inode number doesn't point at an internal * inode, empty space, or static AG metadata. @@ -130,9 +121,11 @@ xfs_verify_dir_ino( struct xfs_mount *mp, xfs_ino_t ino) { - if (!xfs_has_metadir(mp) && xfs_internal_inum(mp, ino)) + if (!xfs_verify_ino(mp, ino)) return false; - return xfs_verify_ino(mp, ino); + if (xfs_is_static_metadata_ino(mp, ino)) + return false; + return true; } /* diff --git a/libxfs/xfs_types.h b/libxfs/xfs_types.h index 06de4b284..6d75a38e7 100644 --- a/libxfs/xfs_types.h +++ b/libxfs/xfs_types.h @@ -233,7 +233,6 @@ bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno, xfs_fsblock_t len); bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); -bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); bool xfs_verify_rtbext(struct xfs_mount *mp, xfs_rtblock_t rtbno, -- 2.50.1