/* Return the AG of the filestream the file or directory belongs to, or NULLAGNUMBER otherwise.  */
xfs_agnumber_t xfs_filestream_lookup_ag(xfs_inode_t *ip)
/* Return the AG of the filestream the file or directory belongs to, or NULLAGNUMBER otherwise.  */
xfs_agnumber_t xfs_filestream_lookup_ag(xfs_inode_t *ip)
{
	xfs_mru_cache_t	*cache;
	fstrm_item_t	*item;
	xfs_agnumber_t	ag;
	int		ref;
	if (!(ip->i_d.di_mode & (S_IFREG | S_IFDIR))) {
		ASSERT(0);
		return NULLAGNUMBER;
	}
	cache = ip->i_mount->m_filestream;
	item = xfs_mru_cache_lookup(cache, ip->i_ino);
	if (!item) {
		TRACE_LOOKUP(ip->i_mount, ip, NULL, NULLAGNUMBER, 0);
		return NULLAGNUMBER;
	}
	ASSERT(ip == item->ip);
	ag = item->ag;
	ref = xfs_filestream_peek_ag(ip->i_mount, ag);
	xfs_mru_cache_done(cache);
	TRACE_LOOKUP(ip->i_mount, ip, item->pip, ag, ref);
	return ag;
}