/* Read in the buffer at the given ptr and return the buffer and the block pointer within the buffer.  */
STATIC int xfs_btree_read_buf_block(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr, int level, int flags, struct xfs_btree_block **block, struct xfs_buf **bpp)
/* Read in the buffer at the given ptr and return the buffer and the block pointer within the buffer.  */
STATIC int xfs_btree_read_buf_block(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr, int level, int flags, struct xfs_btree_block **block, struct xfs_buf **bpp)
{
	struct xfs_mount	*mp = cur->bc_mp;
	xfs_daddr_t		d;
	int			error;
	ASSERT(!(flags & XFS_BUF_TRYLOCK));
	d = xfs_btree_ptr_to_daddr(cur, ptr);
	error = xfs_trans_read_buf(mp, cur->bc_tp, mp->m_ddev_targp, d,
				   mp->m_bsize, flags, bpp);
	if (error)
		return error;
	ASSERT(*bpp != NULL);
	ASSERT(!XFS_BUF_GETERROR(*bpp));
	xfs_btree_set_refs(cur, *bpp);
	*block = XFS_BUF_TO_BLOCK(*bpp);
	error = xfs_btree_check_block(cur, *block, level, *bpp);
	if (error)
		xfs_trans_brelse(cur->bc_tp, *bpp);
	return error;
}