Skip to content

Commit 186f20c

Browse files
author
Darrick J. Wong
committed
xfs: factor out a btree block owner check
Hoist the btree block owner check into a separate helper so that we don't have an ugly multiline if statement. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 2054cf0 commit 186f20c

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

fs/xfs/libxfs/xfs_btree.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,33 @@ xfs_btree_decrement(
17771777
return error;
17781778
}
17791779

1780+
/*
1781+
* Check the btree block owner now that we have the context to know who the
1782+
* real owner is.
1783+
*/
1784+
static inline xfs_failaddr_t
1785+
xfs_btree_check_block_owner(
1786+
struct xfs_btree_cur *cur,
1787+
struct xfs_btree_block *block)
1788+
{
1789+
__u64 owner;
1790+
1791+
if (!xfs_has_crc(cur->bc_mp) ||
1792+
(cur->bc_flags & XFS_BTREE_BMBT_INVALID_OWNER))
1793+
return NULL;
1794+
1795+
owner = xfs_btree_owner(cur);
1796+
if (cur->bc_ops->geom_flags & XFS_BTGEO_LONG_PTRS) {
1797+
if (be64_to_cpu(block->bb_u.l.bb_owner) != owner)
1798+
return __this_address;
1799+
} else {
1800+
if (be32_to_cpu(block->bb_u.s.bb_owner) != owner)
1801+
return __this_address;
1802+
}
1803+
1804+
return NULL;
1805+
}
1806+
17801807
int
17811808
xfs_btree_lookup_get_block(
17821809
struct xfs_btree_cur *cur, /* btree cursor */
@@ -1815,11 +1842,7 @@ xfs_btree_lookup_get_block(
18151842
return error;
18161843

18171844
/* Check the inode owner since the verifiers don't. */
1818-
if (xfs_has_crc(cur->bc_mp) &&
1819-
!(cur->bc_flags & XFS_BTREE_BMBT_INVALID_OWNER) &&
1820-
(cur->bc_ops->geom_flags & XFS_BTGEO_LONG_PTRS) &&
1821-
be64_to_cpu((*blkp)->bb_u.l.bb_owner) !=
1822-
cur->bc_ino.ip->i_ino)
1845+
if (xfs_btree_check_block_owner(cur, *blkp) != NULL)
18231846
goto out_bad;
18241847

18251848
/* Did we get the level we were looking for? */

0 commit comments

Comments
 (0)