From: Christoph Hellwig Date: Mon, 10 Nov 2025 13:23:07 +0000 (+0100) Subject: xfs: move quota locking into xqcheck_commit_dquot X-Git-Tag: v6.19-rc1~164^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2ebb21f8ae1a8cc9414677ac7ddbf5c7cc6f48d;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- diff --git a/fs/xfs/scrub/quotacheck_repair.c b/fs/xfs/scrub/quotacheck_repair.c index 3013211fa6c10..51be8d8d261b2 100644 --- a/fs/xfs/scrub/quotacheck_repair.c +++ b/fs/xfs/scrub/quotacheck_repair.c @@ -52,13 +52,11 @@ xqcheck_commit_dquot( bool dirty = false; int error = 0; - /* Unlock the dquot just long enough to allocate a transaction. */ - mutex_unlock(&dq->q_qlock); error = xchk_trans_alloc(xqc->sc, 0); - mutex_lock(&dq->q_qlock); if (error) return error; + mutex_lock(&dq->q_qlock); xfs_trans_dqjoin(xqc->sc->tp, dq); if (xchk_iscan_aborted(&xqc->iscan)) { @@ -115,23 +113,12 @@ xqcheck_commit_dquot( if (dq->q_id) xfs_qm_adjust_dqtimers(dq); xfs_trans_log_dquot(xqc->sc->tp, dq); - - /* - * Transaction commit unlocks the dquot, so we must re-lock it so that - * the caller can put the reference (which apparently requires a locked - * dquot). - */ - error = xrep_trans_commit(xqc->sc); - mutex_lock(&dq->q_qlock); - return error; + return xrep_trans_commit(xqc->sc); out_unlock: mutex_unlock(&xqc->lock); out_cancel: xchk_trans_cancel(xqc->sc); - - /* Re-lock the dquot so the caller can put the reference. */ - mutex_lock(&dq->q_qlock); return error; } @@ -155,9 +142,7 @@ xqcheck_commit_dqtype( */ xchk_dqiter_init(&cursor, sc, dqtype); while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) { - mutex_lock(&dq->q_qlock); error = xqcheck_commit_dquot(xqc, dqtype, dq); - mutex_unlock(&dq->q_qlock); xfs_qm_dqrele(dq); if (error) break; @@ -188,9 +173,7 @@ xqcheck_commit_dqtype( if (error) return error; - mutex_lock(&dq->q_qlock); error = xqcheck_commit_dquot(xqc, dqtype, dq); - mutex_unlock(&dq->q_qlock); xfs_qm_dqrele(dq); if (error) return error;