/* Calculate how many blocks we need for the new attribute,  */
int xfs_attr_calc_size(struct xfs_inode *ip, int namelen, int valuelen, int *local)
/* Calculate how many blocks we need for the new attribute,  */
int xfs_attr_calc_size(struct xfs_inode *ip, int namelen, int valuelen, int *local)
{
	struct xfs_mount 	*mp = ip->i_mount;
	int			size;
	int			nblks;
	size = xfs_attr_leaf_newentsize(namelen, valuelen,
					mp->m_sb.sb_blocksize, local);
	nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
	if (*local) {
		if (size > (mp->m_sb.sb_blocksize >> 1)) {
			nblks *= 2;
		}
	} else {
		uint	dblocks = XFS_B_TO_FSB(mp, valuelen);
		nblks += dblocks;
		nblks += XFS_NEXTENTADD_SPACE_RES(mp, dblocks, XFS_ATTR_FORK);
	}
	return nblks;
}