/* RETURN VALUES: 0 - success. -ENOSPC - insufficient disk resources. -EIO - i/o error.  */
static int diAllocAny(struct inomap *, int, bool, struct inode *)
/* RETURN VALUES: 0 - success. -ENOSPC - insufficient disk resources. -EIO - i/o error.  */
static int diAllocAny(struct inomap *, int, bool, struct inode *)
{
	int ag, rc;
	int maxag = JFS_SBI(imap->im_ipimap->i_sb)->bmap->db_maxag;
	for (ag = agno + 1; ag <= maxag; ag++) {
		AG_LOCK(imap, ag);
		rc = diAllocAG(imap, ag, dir, ip);
		AG_UNLOCK(imap, ag);
		if (rc != -ENOSPC)
			return (rc);
	}
	for (ag = 0; ag < agno; ag++) {
		AG_LOCK(imap, ag);
		rc = diAllocAG(imap, ag, dir, ip);
		AG_UNLOCK(imap, ag);
		if (rc != -ENOSPC)
			return (rc);
	}
	return -ENOSPC;
}