Skip to content

Commit a2ebb21

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: move quota locking into xqcheck_commit_dquot
Drop two redundant lock roundtrips by not requiring q_lock to be held on entry and return. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 7dd30ac commit a2ebb21

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

fs/xfs/scrub/quotacheck_repair.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ xqcheck_commit_dquot(
5252
bool dirty = false;
5353
int error = 0;
5454

55-
/* Unlock the dquot just long enough to allocate a transaction. */
56-
mutex_unlock(&dq->q_qlock);
5755
error = xchk_trans_alloc(xqc->sc, 0);
58-
mutex_lock(&dq->q_qlock);
5956
if (error)
6057
return error;
6158

59+
mutex_lock(&dq->q_qlock);
6260
xfs_trans_dqjoin(xqc->sc->tp, dq);
6361

6462
if (xchk_iscan_aborted(&xqc->iscan)) {
@@ -115,23 +113,12 @@ xqcheck_commit_dquot(
115113
if (dq->q_id)
116114
xfs_qm_adjust_dqtimers(dq);
117115
xfs_trans_log_dquot(xqc->sc->tp, dq);
118-
119-
/*
120-
* Transaction commit unlocks the dquot, so we must re-lock it so that
121-
* the caller can put the reference (which apparently requires a locked
122-
* dquot).
123-
*/
124-
error = xrep_trans_commit(xqc->sc);
125-
mutex_lock(&dq->q_qlock);
126-
return error;
116+
return xrep_trans_commit(xqc->sc);
127117

128118
out_unlock:
129119
mutex_unlock(&xqc->lock);
130120
out_cancel:
131121
xchk_trans_cancel(xqc->sc);
132-
133-
/* Re-lock the dquot so the caller can put the reference. */
134-
mutex_lock(&dq->q_qlock);
135122
return error;
136123
}
137124

@@ -155,9 +142,7 @@ xqcheck_commit_dqtype(
155142
*/
156143
xchk_dqiter_init(&cursor, sc, dqtype);
157144
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
158-
mutex_lock(&dq->q_qlock);
159145
error = xqcheck_commit_dquot(xqc, dqtype, dq);
160-
mutex_unlock(&dq->q_qlock);
161146
xfs_qm_dqrele(dq);
162147
if (error)
163148
break;
@@ -188,9 +173,7 @@ xqcheck_commit_dqtype(
188173
if (error)
189174
return error;
190175

191-
mutex_lock(&dq->q_qlock);
192176
error = xqcheck_commit_dquot(xqc, dqtype, dq);
193-
mutex_unlock(&dq->q_qlock);
194177
xfs_qm_dqrele(dq);
195178
if (error)
196179
return error;

0 commit comments

Comments
 (0)