/* Compute the worst-case number of indirect blocks that will be used for ip's delayed extent of length "len".  */
STATIC xfs_filblks_t xfs_bmap_worst_indlen(xfs_inode_t *ip, xfs_filblks_t len)
/* Compute the worst-case number of indirect blocks that will be used for ip's delayed extent of length "len".  */
STATIC xfs_filblks_t xfs_bmap_worst_indlen(xfs_inode_t *ip, xfs_filblks_t len)
{
	int		level;
	int		maxrecs;
	xfs_mount_t	*mp;
	xfs_filblks_t	rval;
	mp = ip->i_mount;
	maxrecs = mp->m_bmap_dmxr[0];
	for (level = 0, rval = 0;
	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
	     level++) {
		len += maxrecs - 1;
		do_div(len, maxrecs);
		rval += len;
		if (len == 1)
			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
				level - 1;
		if (level == 0)
			maxrecs = mp->m_bmap_dmxr[1];
	}
	return rval;
}