From: Darrick J. Wong Date: Wed, 12 Apr 2023 02:00:05 +0000 (-0700) Subject: xfs: hoist rmap record flag checks from scrub X-Git-Tag: v6.6.7~2856^2~26^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d7d6d2fd0444904f12e70d9c930556c4eb44337;p=platform%2Fkernel%2Flinux-starfive.git xfs: hoist rmap record flag checks from scrub Move the rmap record flag checks from xchk_rmapbt_rec into xfs_rmap_check_irec so that they are applied everywhere. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c index 641114a..e66ecd7 100644 --- a/fs/xfs/libxfs/xfs_rmap.c +++ b/fs/xfs/libxfs/xfs_rmap.c @@ -212,6 +212,10 @@ xfs_rmap_check_irec( const struct xfs_rmap_irec *irec) { struct xfs_mount *mp = cur->bc_mp; + bool is_inode; + bool is_unwritten; + bool is_bmbt; + bool is_attr; if (irec->rm_blockcount == 0) return __this_address; @@ -232,6 +236,24 @@ xfs_rmap_check_irec( irec->rm_owner >= XFS_RMAP_OWN_MIN))) return __this_address; + /* Check flags. */ + is_inode = !XFS_RMAP_NON_INODE_OWNER(irec->rm_owner); + is_bmbt = irec->rm_flags & XFS_RMAP_BMBT_BLOCK; + is_attr = irec->rm_flags & XFS_RMAP_ATTR_FORK; + is_unwritten = irec->rm_flags & XFS_RMAP_UNWRITTEN; + + if (is_bmbt && irec->rm_offset != 0) + return __this_address; + + if (!is_inode && irec->rm_offset != 0) + return __this_address; + + if (is_unwritten && (is_bmbt || !is_inode || is_attr)) + return __this_address; + + if (!is_inode && (is_bmbt || is_unwritten || is_attr)) + return __this_address; + return NULL; } diff --git a/fs/xfs/scrub/rmap.c b/fs/xfs/scrub/rmap.c index 353cf9d..ef6e4b8 100644 --- a/fs/xfs/scrub/rmap.c +++ b/fs/xfs/scrub/rmap.c @@ -94,10 +94,6 @@ xchk_rmapbt_rec( const union xfs_btree_rec *rec) { struct xfs_rmap_irec irec; - bool non_inode; - bool is_unwritten; - bool is_bmbt; - bool is_attr; if (xfs_rmap_btrec_to_irec(rec, &irec) != NULL || xfs_rmap_check_irec(bs->cur, &irec) != NULL) { @@ -105,24 +101,6 @@ xchk_rmapbt_rec( return 0; } - /* Check flags. */ - non_inode = XFS_RMAP_NON_INODE_OWNER(irec.rm_owner); - is_bmbt = irec.rm_flags & XFS_RMAP_BMBT_BLOCK; - is_attr = irec.rm_flags & XFS_RMAP_ATTR_FORK; - is_unwritten = irec.rm_flags & XFS_RMAP_UNWRITTEN; - - if (is_bmbt && irec.rm_offset != 0) - xchk_btree_set_corrupt(bs->sc, bs->cur, 0); - - if (non_inode && irec.rm_offset != 0) - xchk_btree_set_corrupt(bs->sc, bs->cur, 0); - - if (is_unwritten && (is_bmbt || non_inode || is_attr)) - xchk_btree_set_corrupt(bs->sc, bs->cur, 0); - - if (non_inode && (is_bmbt || is_unwritten || is_attr)) - xchk_btree_set_corrupt(bs->sc, bs->cur, 0); - xchk_rmapbt_xref(bs->sc, &irec); return 0; }