/* The inode is expected to already been mapped to its buffer and read in once, thus we can use the mapping information stored in the inode rather than calling xfs_imap(). This allows us to avoid the overhead of looking at the inode btree for small block file systems (see xfs_imap()).  */
int xfs_itobp(xfs_mount_t *mp, xfs_trans_t *tp, xfs_inode_t *ip, xfs_dinode_t **dipp, xfs_buf_t **bpp, uint buf_flags)
/* The inode is expected to already been mapped to its buffer and read in once, thus we can use the mapping information stored in the inode rather than calling xfs_imap(). This allows us to avoid the overhead of looking at the inode btree for small block file systems (see xfs_imap()).  */
int xfs_itobp(xfs_mount_t *mp, xfs_trans_t *tp, xfs_inode_t *ip, xfs_dinode_t **dipp, xfs_buf_t **bpp, uint buf_flags)
{
	xfs_buf_t	*bp;
	int		error;
	ASSERT(ip->i_imap.im_blkno != 0);
	error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, buf_flags, 0);
	if (error)
		return error;
	if (!bp) {
		ASSERT(buf_flags & XFS_BUF_TRYLOCK);
		ASSERT(tp == NULL);
		*bpp = NULL;
		return EAGAIN;
	}
	*dipp = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
	*bpp = bp;
	return 0;
}