Skip to content

Commit b6d2ab2

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: move quota locking into xrep_quota_item
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 a2ebb21 commit b6d2ab2

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

fs/xfs/scrub/quota_repair.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,13 @@ xrep_quota_item(
184184
/*
185185
* We might need to fix holes in the bmap record for the storage
186186
* backing this dquot, so we need to lock the dquot and the quota file.
187-
* dqiterate gave us a locked dquot, so drop the dquot lock to get the
188-
* ILOCK_EXCL.
189187
*/
190-
mutex_unlock(&dq->q_qlock);
191188
xchk_ilock(sc, XFS_ILOCK_EXCL);
192189
mutex_lock(&dq->q_qlock);
193-
194190
error = xrep_quota_item_bmap(sc, dq, &dirty);
195191
xchk_iunlock(sc, XFS_ILOCK_EXCL);
196192
if (error)
197-
return error;
193+
goto out_unlock_dquot;
198194

199195
/* Check the limits. */
200196
if (dq->q_blk.softlimit > dq->q_blk.hardlimit) {
@@ -246,7 +242,7 @@ xrep_quota_item(
246242
xrep_quota_item_timer(sc, &dq->q_rtb, &dirty);
247243

248244
if (!dirty)
249-
return 0;
245+
goto out_unlock_dquot;
250246

251247
trace_xrep_dquot_item(sc->mp, dq->q_type, dq->q_id);
252248

@@ -257,8 +253,10 @@ xrep_quota_item(
257253
xfs_qm_adjust_dqtimers(dq);
258254
}
259255
xfs_trans_log_dquot(sc->tp, dq);
260-
error = xfs_trans_roll(&sc->tp);
261-
mutex_lock(&dq->q_qlock);
256+
return xfs_trans_roll(&sc->tp);
257+
258+
out_unlock_dquot:
259+
mutex_unlock(&dq->q_qlock);
262260
return error;
263261
}
264262

@@ -512,9 +510,7 @@ xrep_quota_problems(
512510

513511
xchk_dqiter_init(&cursor, sc, dqtype);
514512
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
515-
mutex_lock(&dq->q_qlock);
516513
error = xrep_quota_item(&rqi, dq);
517-
mutex_unlock(&dq->q_qlock);
518514
xfs_qm_dqrele(dq);
519515
if (error)
520516
break;

0 commit comments

Comments
 (0)