Commit e1e55aaf authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: refactor short form btree pointer verification

Now that we have xfs_verify_agbno, use it to verify short form btree
pointers instead of open-coding them.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 8368a601
...@@ -4614,19 +4614,19 @@ xfs_btree_sblock_verify( ...@@ -4614,19 +4614,19 @@ xfs_btree_sblock_verify(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
xfs_agblock_t agno;
/* numrecs verification */ /* numrecs verification */
if (be16_to_cpu(block->bb_numrecs) > max_recs) if (be16_to_cpu(block->bb_numrecs) > max_recs)
return false; return false;
/* sibling pointer verification */ /* sibling pointer verification */
if (!block->bb_u.s.bb_leftsib || agno = xfs_daddr_to_agno(mp, XFS_BUF_ADDR(bp));
(be32_to_cpu(block->bb_u.s.bb_leftsib) >= mp->m_sb.sb_agblocks && if (block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) &&
block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK))) !xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_leftsib)))
return false; return false;
if (!block->bb_u.s.bb_rightsib || if (block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK) &&
(be32_to_cpu(block->bb_u.s.bb_rightsib) >= mp->m_sb.sb_agblocks && !xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_rightsib)))
block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK)))
return false; return false;
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment