diff options
Diffstat (limited to 'fs/xfs/quota/xfs_dquot.c')
-rw-r--r-- | fs/xfs/quota/xfs_dquot.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index 591ca6602bfb..6543c0b29753 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
@@ -73,6 +73,8 @@ int xfs_dqreq_num; | |||
73 | int xfs_dqerror_mod = 33; | 73 | int xfs_dqerror_mod = 33; |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | static struct lock_class_key xfs_dquot_other_class; | ||
77 | |||
76 | /* | 78 | /* |
77 | * Allocate and initialize a dquot. We don't always allocate fresh memory; | 79 | * Allocate and initialize a dquot. We don't always allocate fresh memory; |
78 | * we try to reclaim a free dquot if the number of incore dquots are above | 80 | * we try to reclaim a free dquot if the number of incore dquots are above |
@@ -139,7 +141,15 @@ xfs_qm_dqinit( | |||
139 | ASSERT(dqp->q_trace); | 141 | ASSERT(dqp->q_trace); |
140 | xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT"); | 142 | xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT"); |
141 | #endif | 143 | #endif |
142 | } | 144 | } |
145 | |||
146 | /* | ||
147 | * In either case we need to make sure group quotas have a different | ||
148 | * lock class than user quotas, to make sure lockdep knows we can | ||
149 | * locks of one of each at the same time. | ||
150 | */ | ||
151 | if (!(type & XFS_DQ_USER)) | ||
152 | lockdep_set_class(&dqp->q_qlock, &xfs_dquot_other_class); | ||
143 | 153 | ||
144 | /* | 154 | /* |
145 | * log item gets initialized later | 155 | * log item gets initialized later |
@@ -421,7 +431,7 @@ xfs_qm_dqalloc( | |||
421 | /* | 431 | /* |
422 | * Initialize the bmap freelist prior to calling bmapi code. | 432 | * Initialize the bmap freelist prior to calling bmapi code. |
423 | */ | 433 | */ |
424 | XFS_BMAP_INIT(&flist, &firstblock); | 434 | xfs_bmap_init(&flist, &firstblock); |
425 | xfs_ilock(quotip, XFS_ILOCK_EXCL); | 435 | xfs_ilock(quotip, XFS_ILOCK_EXCL); |
426 | /* | 436 | /* |
427 | * Return if this type of quotas is turned off while we didn't | 437 | * Return if this type of quotas is turned off while we didn't |
@@ -1383,6 +1393,12 @@ xfs_dqunlock_nonotify( | |||
1383 | mutex_unlock(&(dqp->q_qlock)); | 1393 | mutex_unlock(&(dqp->q_qlock)); |
1384 | } | 1394 | } |
1385 | 1395 | ||
1396 | /* | ||
1397 | * Lock two xfs_dquot structures. | ||
1398 | * | ||
1399 | * To avoid deadlocks we always lock the quota structure with | ||
1400 | * the lowerd id first. | ||
1401 | */ | ||
1386 | void | 1402 | void |
1387 | xfs_dqlock2( | 1403 | xfs_dqlock2( |
1388 | xfs_dquot_t *d1, | 1404 | xfs_dquot_t *d1, |
@@ -1392,18 +1408,16 @@ xfs_dqlock2( | |||
1392 | ASSERT(d1 != d2); | 1408 | ASSERT(d1 != d2); |
1393 | if (be32_to_cpu(d1->q_core.d_id) > | 1409 | if (be32_to_cpu(d1->q_core.d_id) > |
1394 | be32_to_cpu(d2->q_core.d_id)) { | 1410 | be32_to_cpu(d2->q_core.d_id)) { |
1395 | xfs_dqlock(d2); | 1411 | mutex_lock(&d2->q_qlock); |
1396 | xfs_dqlock(d1); | 1412 | mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED); |
1397 | } else { | 1413 | } else { |
1398 | xfs_dqlock(d1); | 1414 | mutex_lock(&d1->q_qlock); |
1399 | xfs_dqlock(d2); | 1415 | 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 | } | 1416 | } |
1417 | } else if (d1) { | ||
1418 | mutex_lock(&d1->q_qlock); | ||
1419 | } else if (d2) { | ||
1420 | mutex_lock(&d2->q_qlock); | ||
1407 | } | 1421 | } |
1408 | } | 1422 | } |
1409 | 1423 | ||