From: Darrick J. Wong Date: Thu, 21 Nov 2024 00:24:19 +0000 (-0800) Subject: xfs_repair: check metadata inode flag X-Git-Tag: v6.13.0~149 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=34a4618b759787d2706efae4cd12df6082a5b75a;p=xfsprogs-dev.git xfs_repair: check metadata inode flag Check whether or not the metadata inode flag is set appropriately. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- diff --git a/repair/dinode.c b/repair/dinode.c index e217e037f..5dd7edfa3 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -2331,6 +2331,26 @@ _("Bad extent size hint %u on inode %" PRIu64 ", "), } } +static inline bool +should_have_metadir_iflag( + struct xfs_mount *mp, + xfs_ino_t ino) +{ + if (ino == mp->m_sb.sb_metadirino) + return true; + if (ino == mp->m_sb.sb_rbmino) + return true; + if (ino == mp->m_sb.sb_rsumino) + return true; + if (ino == mp->m_sb.sb_uquotino) + return true; + if (ino == mp->m_sb.sb_gquotino) + return true; + if (ino == mp->m_sb.sb_pquotino) + return true; + return false; +} + /* * 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 @@ -2680,6 +2700,27 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"), } } + if (flags2 & XFS_DIFLAG2_METADATA) { + xfs_failaddr_t fa; + + fa = libxfs_dinode_verify_metadir(mp, dino, di_mode, + be16_to_cpu(dino->di_flags), flags2); + if (fa) { + if (!uncertain) + do_warn( + _("inode %" PRIu64 " is incorrectly marked as metadata\n"), + lino); + goto clear_bad_out; + } + } else if (xfs_has_metadir(mp) && + should_have_metadir_iflag(mp, lino)) { + if (!uncertain) + do_warn( + _("inode %" PRIu64 " should be marked as metadata\n"), + lino); + goto clear_bad_out; + } + if ((flags2 & XFS_DIFLAG2_REFLINK) && !xfs_has_reflink(mp)) { if (!uncertain) {