summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2025-11-10 14:23:08 +0100
committerCarlos Maiolino <cem@kernel.org>2025-11-11 11:45:58 +0100
commitb6d2ab27cc84b19afdf72eac1361fb343c4e0186 (patch)
treec0a3da8b36e5e85afea717833db231abab2bd6bb
parenta2ebb21f8ae1a8cc9414677ac7ddbf5c7cc6f48d (diff)
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>
-rw-r--r--fs/xfs/scrub/quota_repair.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/fs/xfs/scrub/quota_repair.c b/fs/xfs/scrub/quota_repair.c
index dae4889bdc84..b1d661aa5f06 100644
--- a/fs/xfs/scrub/quota_repair.c
+++ b/fs/xfs/scrub/quota_repair.c
@@ -184,17 +184,13 @@ xrep_quota_item(
/*
* 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.
- * 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);
mutex_lock(&dq->q_qlock);
-
error = xrep_quota_item_bmap(sc, dq, &dirty);
xchk_iunlock(sc, XFS_ILOCK_EXCL);
if (error)
- return error;
+ goto out_unlock_dquot;
/* Check the limits. */
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);
if (!dirty)
- return 0;
+ goto out_unlock_dquot;
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_trans_log_dquot(sc->tp, dq);
- error = xfs_trans_roll(&sc->tp);
- mutex_lock(&dq->q_qlock);
+ return xfs_trans_roll(&sc->tp);
+
+out_unlock_dquot:
+ mutex_unlock(&dq->q_qlock);
return error;
}
@@ -512,9 +510,7 @@ xrep_quota_problems(
xchk_dqiter_init(&cursor, sc, dqtype);
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
- mutex_lock(&dq->q_qlock);
error = xrep_quota_item(&rqi, dq);
- mutex_unlock(&dq->q_qlock);
xfs_qm_dqrele(dq);
if (error)
break;