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>
This commit is contained in:
Christoph Hellwig 2025-11-10 14:23:08 +01:00 committed by Carlos Maiolino
parent a2ebb21f8a
commit b6d2ab27cc
1 changed files with 6 additions and 10 deletions

View File

@ -184,17 +184,13 @@ xrep_quota_item(
/* /*
* We might need to fix holes in the bmap record for the storage * We might need to fix holes in the bmap record for the storage
* backing this dquot, so we need to lock the dquot and the quota file. * backing this dquot, so we need to lock the dquot and the quota file.
* dqiterate gave us a locked dquot, so drop the dquot lock to get the
* ILOCK_EXCL.
*/ */
mutex_unlock(&dq->q_qlock);
xchk_ilock(sc, XFS_ILOCK_EXCL); xchk_ilock(sc, XFS_ILOCK_EXCL);
mutex_lock(&dq->q_qlock); mutex_lock(&dq->q_qlock);
error = xrep_quota_item_bmap(sc, dq, &dirty); error = xrep_quota_item_bmap(sc, dq, &dirty);
xchk_iunlock(sc, XFS_ILOCK_EXCL); xchk_iunlock(sc, XFS_ILOCK_EXCL);
if (error) if (error)
return error; goto out_unlock_dquot;
/* Check the limits. */ /* Check the limits. */
if (dq->q_blk.softlimit > dq->q_blk.hardlimit) { if (dq->q_blk.softlimit > dq->q_blk.hardlimit) {
@ -246,7 +242,7 @@ xrep_quota_item(
xrep_quota_item_timer(sc, &dq->q_rtb, &dirty); xrep_quota_item_timer(sc, &dq->q_rtb, &dirty);
if (!dirty) if (!dirty)
return 0; goto out_unlock_dquot;
trace_xrep_dquot_item(sc->mp, dq->q_type, dq->q_id); trace_xrep_dquot_item(sc->mp, dq->q_type, dq->q_id);
@ -257,8 +253,10 @@ xrep_quota_item(
xfs_qm_adjust_dqtimers(dq); xfs_qm_adjust_dqtimers(dq);
} }
xfs_trans_log_dquot(sc->tp, dq); xfs_trans_log_dquot(sc->tp, dq);
error = xfs_trans_roll(&sc->tp); return xfs_trans_roll(&sc->tp);
mutex_lock(&dq->q_qlock);
out_unlock_dquot:
mutex_unlock(&dq->q_qlock);
return error; return error;
} }
@ -512,9 +510,7 @@ xrep_quota_problems(
xchk_dqiter_init(&cursor, sc, dqtype); xchk_dqiter_init(&cursor, sc, dqtype);
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) { while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
mutex_lock(&dq->q_qlock);
error = xrep_quota_item(&rqi, dq); error = xrep_quota_item(&rqi, dq);
mutex_unlock(&dq->q_qlock);
xfs_qm_dqrele(dq); xfs_qm_dqrele(dq);
if (error) if (error)
break; break;