/* Release the group dquot pointers the user dquots may be carrying around as a hint. mplist is locked on entry and exit.  */
STATIC void xfs_qm_detach_gdquots(xfs_mount_t *mp)
/* Release the group dquot pointers the user dquots may be carrying around as a hint. mplist is locked on entry and exit.  */
STATIC void xfs_qm_detach_gdquots(xfs_mount_t *mp)
{
	xfs_dquot_t	*dqp, *gdqp;
	int		nrecl;
 again:
	ASSERT(XFS_QM_IS_MPLIST_LOCKED(mp));
	dqp = XFS_QI_MPLNEXT(mp);
	while (dqp) {
		xfs_dqlock(dqp);
		if ((gdqp = dqp->q_gdquot)) {
			xfs_dqlock(gdqp);
			dqp->q_gdquot = NULL;
		}
		xfs_dqunlock(dqp);
		if (gdqp) {
			nrecl = XFS_QI_MPLRECLAIMS(mp);
			xfs_qm_mplist_unlock(mp);
			xfs_qm_dqput(gdqp);
			xfs_qm_mplist_lock(mp);
			if (nrecl != XFS_QI_MPLRECLAIMS(mp))
				goto again;
		}
		dqp = dqp->MPL_NEXT;
	}
}