Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 129935
b: refs/heads/master
c: 4f2d4ac
h: refs/heads/master
i:
  129933: 74ad21a
  129931: 118b2fc
  129927: 706f236
  129919: 5f575e7
v: v3
  • Loading branch information
Christoph Hellwig authored and Lachlan McIlroy committed Jan 19, 2009
1 parent f37bd7c commit f2cbab2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 080dda7f5e8e8df95bcd17a5345c276e365a2054
refs/heads/master: 4f2d4ac6e5eb7d72e8df7f3fbf67a78dab8b91cf
24 changes: 14 additions & 10 deletions trunk/fs/xfs/quota/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,12 @@ xfs_dqunlock_nonotify(
mutex_unlock(&(dqp->q_qlock));
}

/*
* Lock two xfs_dquot structures.
*
* To avoid deadlocks we always lock the quota structure with
* the lowerd id first.
*/
void
xfs_dqlock2(
xfs_dquot_t *d1,
Expand All @@ -1392,18 +1398,16 @@ xfs_dqlock2(
ASSERT(d1 != d2);
if (be32_to_cpu(d1->q_core.d_id) >
be32_to_cpu(d2->q_core.d_id)) {
xfs_dqlock(d2);
xfs_dqlock(d1);
mutex_lock(&d2->q_qlock);
mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
} else {
xfs_dqlock(d1);
xfs_dqlock(d2);
}
} else {
if (d1) {
xfs_dqlock(d1);
} else if (d2) {
xfs_dqlock(d2);
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);
}
}

Expand Down
10 changes: 10 additions & 0 deletions trunk/fs/xfs/quota/xfs_dquot.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ typedef struct xfs_dquot {
#define dq_hashlist q_lists.dqm_hashlist
#define dq_flags q_lists.dqm_flags

/*
* Lock hierachy for q_qlock:
* XFS_QLOCK_NORMAL is the implicit default,
* XFS_QLOCK_NESTED is the dquot with the higher id in xfs_dqlock2
*/
enum {
XFS_QLOCK_NORMAL = 0,
XFS_QLOCK_NESTED,
};

#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++)

#ifdef DEBUG
Expand Down

0 comments on commit f2cbab2

Please sign in to comment.