/* To avoid deadlocks we always lock the quota structure with the lowerd id first.  */
void xfs_dqlock2(xfs_dquot_t *d1, xfs_dquot_t *d2)
/* To avoid deadlocks we always lock the quota structure with the lowerd id first.  */
void xfs_dqlock2(xfs_dquot_t *d1, xfs_dquot_t *d2)
{
	if (d1 && d2) {
		ASSERT(d1 != d2);
		if (be32_to_cpu(d1->q_core.d_id) >
		    be32_to_cpu(d2->q_core.d_id)) {
			mutex_lock(&d2->q_qlock);
			mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
		} else {
			mutex_lock(&d1->q_qlock);
			mutex_lock_nested(&d2->q_qlock, XFS_QLOCK_NESTED);
		}
	} else if (d1) {
		mutex_lock(&d1->q_qlock);
	} else if (d2) {
		mutex_lock(&d2->q_qlock);
	}
}