]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: move quota locking into xrep_quota_item
authorChristoph Hellwig <hch@lst.de>
Mon, 10 Nov 2025 13:23:08 +0000 (14:23 +0100)
committerCarlos Maiolino <cem@kernel.org>
Tue, 11 Nov 2025 10:45:58 +0000 (11:45 +0100)
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>
fs/xfs/scrub/quota_repair.c

index dae4889bdc8460ca6b253ac98fcb5470a4126be6..b1d661aa5f063688c01ad9dbd6f16e1ebe5dee21 100644 (file)
@@ -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;