From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/17] xfs: consolidate q_qlock locking in xfs_qm_dqget and xfs_qm_dqget_inode
Date: Wed, 15 Oct 2025 14:05:30 -0700 [thread overview]
Message-ID: <20251015210530.GC2591640@frogsfrogsfrogs> (raw)
In-Reply-To: <20251013024851.4110053-8-hch@lst.de>
On Mon, Oct 13, 2025 at 11:48:08AM +0900, Christoph Hellwig wrote:
> Move taking q_qlock from the cache lookup / insert helpers into the
> main functions and do it just before returning to the caller.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Makes sense that dqget returns a qlock'd dquot no matter where it came
from
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_dquot.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index ceddbbb41999..a6030c53a1f9 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -826,15 +826,13 @@ xfs_qm_dqget_cache_lookup(
>
> trace_xfs_dqget_hit(dqp);
> XFS_STATS_INC(mp, xs_qm_dqcachehits);
> - mutex_lock(&dqp->q_qlock);
> return dqp;
> }
>
> /*
> * Try to insert a new dquot into the in-core cache. If an error occurs the
> * caller should throw away the dquot and start over. Otherwise, the dquot
> - * is returned locked (and held by the cache) as if there had been a cache
> - * hit.
> + * is returned (and held by the cache) as if there had been a cache hit.
> *
> * The insert needs to be done under memalloc_nofs context because the radix
> * tree can do memory allocation during insert. The qi->qi_tree_lock is taken in
> @@ -862,8 +860,6 @@ xfs_qm_dqget_cache_insert(
> goto out_unlock;
> }
>
> - /* Return a locked dquot to the caller, with a reference taken. */
> - mutex_lock(&dqp->q_qlock);
> lockref_init(&dqp->q_lockref);
> qi->qi_dquots++;
>
> @@ -921,10 +917,8 @@ xfs_qm_dqget(
>
> restart:
> dqp = xfs_qm_dqget_cache_lookup(mp, qi, tree, id);
> - if (dqp) {
> - *O_dqpp = dqp;
> - return 0;
> - }
> + if (dqp)
> + goto found;
>
> error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp);
> if (error)
> @@ -942,7 +936,9 @@ xfs_qm_dqget(
> }
>
> trace_xfs_dqget_miss(dqp);
> +found:
> *O_dqpp = dqp;
> + mutex_lock(&dqp->q_qlock);
> return 0;
> }
>
> @@ -1017,10 +1013,8 @@ xfs_qm_dqget_inode(
>
> restart:
> dqp = xfs_qm_dqget_cache_lookup(mp, qi, tree, id);
> - if (dqp) {
> - *O_dqpp = dqp;
> - return 0;
> - }
> + if (dqp)
> + goto found;
>
> /*
> * Dquot cache miss. We don't want to keep the inode lock across
> @@ -1046,7 +1040,6 @@ xfs_qm_dqget_inode(
> if (dqp1) {
> xfs_qm_dqdestroy(dqp);
> dqp = dqp1;
> - mutex_lock(&dqp->q_qlock);
> goto dqret;
> }
> } else {
> @@ -1069,7 +1062,9 @@ xfs_qm_dqget_inode(
> dqret:
> xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
> trace_xfs_dqget_miss(dqp);
> +found:
> *O_dqpp = dqp;
> + mutex_lock(&dqp->q_qlock);
> return 0;
> }
>
> --
> 2.47.3
>
>
next prev parent reply other threads:[~2025-10-15 21:05 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 2:48 cleanup quota locking Christoph Hellwig
2025-10-13 2:48 ` [PATCH 01/17] xfs: make qi_dquots a 64-bit value Christoph Hellwig
2025-10-14 23:16 ` Darrick J. Wong
2025-10-15 4:48 ` Christoph Hellwig
2025-10-13 2:48 ` [PATCH 02/17] xfs: remove xfs_dqunlock and friends Christoph Hellwig
2025-10-14 23:17 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 03/17] xfs: don't lock the dquot before return in xqcheck_commit_dquot Christoph Hellwig
2025-10-14 23:22 ` Darrick J. Wong
2025-10-15 5:00 ` Christoph Hellwig
2025-10-15 20:27 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 04/17] xfs: don't lock the dquot before return in xrep_quota_item Christoph Hellwig
2025-10-14 23:24 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 05/17] xfs: use a lockref for the xfs_dquot reference count Christoph Hellwig
2025-10-15 21:02 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 06/17] xfs: remove xfs_qm_dqput and optimize dropping dquot references Christoph Hellwig
2025-10-15 21:04 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 07/17] xfs: consolidate q_qlock locking in xfs_qm_dqget and xfs_qm_dqget_inode Christoph Hellwig
2025-10-15 21:05 ` Darrick J. Wong [this message]
2025-10-13 2:48 ` [PATCH 08/17] xfs: xfs_qm_dqattach_one is never called with a non-NULL *IO_idqpp Christoph Hellwig
2025-10-14 23:27 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 09/17] xfs: fold xfs_qm_dqattach_one into xfs_qm_dqget_inode Christoph Hellwig
2025-10-15 21:13 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 10/17] xfs: return the dquot unlocked from xfs_qm_dqget Christoph Hellwig
2025-10-15 21:17 ` Darrick J. Wong
2025-10-15 21:18 ` Darrick J. Wong
2025-10-16 4:21 ` Christoph Hellwig
2025-10-13 2:48 ` [PATCH 11/17] xfs: remove q_qlock locking in xfs_qm_scall_setqlim Christoph Hellwig
2025-10-15 21:17 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 12/17] xfs: push q_qlock acquisition from xchk_dquot_iter to the callers Christoph Hellwig
2025-10-15 21:19 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 13/17] xfs: move q_qlock locking into xchk_quota_item Christoph Hellwig
2025-10-15 21:19 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 14/17] xfs: move q_qlock locking into xqcheck_compare_dquot Christoph Hellwig
2025-10-15 21:20 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 15/17] xfs: move q_qlock acquisition into xqcheck_commit_dquot Christoph Hellwig
2025-10-15 21:20 ` Darrick J. Wong
2025-10-16 4:22 ` Christoph Hellwig
2025-10-13 2:48 ` [PATCH 16/17] xfs: move xfs_dquot_tree calls into xfs_qm_dqget_cache_{lookup,insert} Christoph Hellwig
2025-10-15 21:21 ` Darrick J. Wong
2025-10-13 2:48 ` [PATCH 17/17] xfs: reduce ilock roundtrips in xfs_qm_vop_dqalloc Christoph Hellwig
2025-10-15 21:27 ` Darrick J. Wong
2025-10-16 4:23 ` Christoph Hellwig
2025-10-16 15:59 ` Darrick J. Wong
2025-10-17 3:50 ` Christoph Hellwig
2025-10-17 23:09 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251015210530.GC2591640@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.