Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 280317
b: refs/heads/master
c: bf72de3
h: refs/heads/master
i:
  280315: 7045cf6
v: v3
  • Loading branch information
Christoph Hellwig authored and Ben Myers committed Dec 15, 2011
1 parent feadc02 commit 37dfd8f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 61 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: 92678554abfc2a2f2727ad168da87d8d434ac904
refs/heads/master: bf72de3194e73fa210a904b0bd951135286bb385
97 changes: 38 additions & 59 deletions trunk/fs/xfs/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@
#include "xfs_qm.h"
#include "xfs_trace.h"


/*
LOCK ORDER
inode lock (ilock)
dquot hash-chain lock (hashlock)
xqm dquot freelist lock (freelistlock
mount's dquot list lock (mplistlock)
user dquot lock - lock ordering among dquots is based on the uid or gid
group dquot lock - similar to udquots. Between the two dquots, the udquot
has to be locked first.
pin lock - the dquot lock must be held to take this lock.
flush lock - ditto.
*/
* Lock order:
*
* ip->i_lock
* qh->qh_lock
* qi->qi_dqlist_lock
* dquot->q_qlock (xfs_dqlock() and friends)
* dquot->q_flush (xfs_dqflock() and friends)
* xfs_Gqm->qm_dqfrlist_lock
*
* If two dquots need to be locked the order is user before group/project,
* otherwise by the lowest id first, see xfs_dqlock2.
*/

#ifdef DEBUG
xfs_buftarg_t *xfs_dqerror_target;
Expand Down Expand Up @@ -984,69 +983,49 @@ xfs_qm_dqget(
*/
void
xfs_qm_dqput(
xfs_dquot_t *dqp)
struct xfs_dquot *dqp)
{
xfs_dquot_t *gdqp;
struct xfs_dquot *gdqp;

ASSERT(dqp->q_nrefs > 0);
ASSERT(XFS_DQ_IS_LOCKED(dqp));

trace_xfs_dqput(dqp);

if (dqp->q_nrefs != 1) {
dqp->q_nrefs--;
recurse:
if (--dqp->q_nrefs > 0) {
xfs_dqunlock(dqp);
return;
}

trace_xfs_dqput_free(dqp);

mutex_lock(&xfs_Gqm->qm_dqfrlist_lock);
if (list_empty(&dqp->q_freelist)) {
list_add_tail(&dqp->q_freelist, &xfs_Gqm->qm_dqfrlist);
xfs_Gqm->qm_dqfrlist_cnt++;
}
mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);

/*
* drop the dqlock and acquire the freelist and dqlock
* in the right order; but try to get it out-of-order first
* If we just added a udquot to the freelist, then we want to release
* the gdquot reference that it (probably) has. Otherwise it'll keep
* the gdquot from getting reclaimed.
*/
if (!mutex_trylock(&xfs_Gqm->qm_dqfrlist_lock)) {
trace_xfs_dqput_wait(dqp);
xfs_dqunlock(dqp);
mutex_lock(&xfs_Gqm->qm_dqfrlist_lock);
xfs_dqlock(dqp);
gdqp = dqp->q_gdquot;
if (gdqp) {
xfs_dqlock(gdqp);
dqp->q_gdquot = NULL;
}
xfs_dqunlock(dqp);

while (1) {
gdqp = NULL;

/* We can't depend on nrefs being == 1 here */
if (--dqp->q_nrefs == 0) {
trace_xfs_dqput_free(dqp);

if (list_empty(&dqp->q_freelist)) {
list_add_tail(&dqp->q_freelist, &xfs_Gqm->qm_dqfrlist);
xfs_Gqm->qm_dqfrlist_cnt++;
}

/*
* If we just added a udquot to the freelist, then
* we want to release the gdquot reference that
* it (probably) has. Otherwise it'll keep the
* gdquot from getting reclaimed.
*/
if ((gdqp = dqp->q_gdquot)) {
/*
* Avoid a recursive dqput call
*/
xfs_dqlock(gdqp);
dqp->q_gdquot = NULL;
}
}
xfs_dqunlock(dqp);

/*
* If we had a group quota inside the user quota as a hint,
* release it now.
*/
if (! gdqp)
break;
/*
* If we had a group quota hint, release it now.
*/
if (gdqp) {
dqp = gdqp;
goto recurse;
}
mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
}

/*
Expand Down
4 changes: 3 additions & 1 deletion trunk/fs/xfs/xfs_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,9 @@ xfs_qm_dqreclaim_one(void)
restart:
list_for_each_entry(dqp, &xfs_Gqm->qm_dqfrlist, q_freelist) {
struct xfs_mount *mp = dqp->q_mount;
xfs_dqlock(dqp);

if (!xfs_dqlock_nowait(dqp))
continue;

/*
* This dquot has already been grabbed by dqlookup.
Expand Down

0 comments on commit 37dfd8f

Please sign in to comment.