aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/quota/xfs_dquot.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-01-18 20:03:19 -0500
committerLachlan McIlroy <lachlan@sgi.com>2009-01-18 22:44:52 -0500
commit4f2d4ac6e5eb7d72e8df7f3fbf67a78dab8b91cf (patch)
tree821d74c2055ebbc8070db1e881762bcc805e90a5 /fs/xfs/quota/xfs_dquot.c
parent080dda7f5e8e8df95bcd17a5345c276e365a2054 (diff)
xfs: lockdep annotations for xfs_dqlock2
xfs_dqlock2 locks two xfs_dquots, which is fine as it always locks the dquot with the lower id first. Use mutex_lock_nested to tell lockdep about this fact. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/quota/xfs_dquot.c')
-rw-r--r--fs/xfs/quota/xfs_dquot.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 591ca6602bfb..36d1bb6140d1 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -1383,6 +1383,12 @@ xfs_dqunlock_nonotify(
1383 mutex_unlock(&(dqp->q_qlock)); 1383 mutex_unlock(&(dqp->q_qlock));
1384} 1384}
1385 1385
1386/*
1387 * Lock two xfs_dquot structures.
1388 *
1389 * To avoid deadlocks we always lock the quota structure with
1390 * the lowerd id first.
1391 */
1386void 1392void
1387xfs_dqlock2( 1393xfs_dqlock2(
1388 xfs_dquot_t *d1, 1394 xfs_dquot_t *d1,
@@ -1392,18 +1398,16 @@ xfs_dqlock2(
1392 ASSERT(d1 != d2); 1398 ASSERT(d1 != d2);
1393 if (be32_to_cpu(d1->q_core.d_id) > 1399 if (be32_to_cpu(d1->q_core.d_id) >
1394 be32_to_cpu(d2->q_core.d_id)) { 1400 be32_to_cpu(d2->q_core.d_id)) {
1395 xfs_dqlock(d2); 1401 mutex_lock(&d2->q_qlock);
1396 xfs_dqlock(d1); 1402 mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
1397 } else { 1403 } else {
1398 xfs_dqlock(d1); 1404 mutex_lock(&d1->q_qlock);
1399 xfs_dqlock(d2); 1405 mutex_lock_nested(&d2->q_qlock, XFS_QLOCK_NESTED);
1400 }
1401 } else {
1402 if (d1) {
1403 xfs_dqlock(d1);
1404 } else if (d2) {
1405 xfs_dqlock(d2);
1406 } 1406 }
1407 } else if (d1) {
1408 mutex_lock(&d1->q_qlock);
1409 } else if (d2) {
1410 mutex_lock(&d2->q_qlock);
1407 } 1411 }
1408} 1412}
1409 1413