Re: [PATCH 3/3] xfs: work around sparse context tracking in xfs_qm_dquot_isolate

"Darrick J. Wong" <[email protected]>
Newsgroups org.kernel.vger.linux-sparse,org.kernel.vger.linux-kernel,org.kernel.vger.linux-xfs
Message-ID <20251114170623.GK196370@frogsfrogsfrogs>
On Fri, Nov 14, 2025 at 06:52:25AM +0100, Christoph Hellwig wrote:
> sparse gets confused by the goto after spin_trylock:
> 
> fs/xfs/xfs_qm.c:486:33: warning: context imbalance in 'xfs_qm_dquot_isolate' - different lock contexts for basic block
> 
> work around this by duplicating the trivial amount of code after the
> label.

Might want to leave a code comment about shutting up sparse so that
someone doesn't revert this change to optimize LOC.  That said ...
what is the differing lock context?  Does sparse not understand the
spin_trylock?

> Signed-off-by: Christoph Hellwig <[email protected]>

Reviewed-by: "Darrick J. Wong" <[email protected]>

--D

> ---
>  fs/xfs/xfs_qm.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index 95be67ac6eb4..66d25ac9600b 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -422,8 +422,11 @@ xfs_qm_dquot_isolate(
>  	struct xfs_qm_isolate	*isol = arg;
>  	enum lru_status		ret = LRU_SKIP;
>  
> -	if (!spin_trylock(&dqp->q_lockref.lock))
> -		goto out_miss_busy;
> +	if (!spin_trylock(&dqp->q_lockref.lock)) {
> +		trace_xfs_dqreclaim_busy(dqp);
> +		XFS_STATS_INC(dqp->q_mount, xs_qm_dqreclaim_misses);
> +		return LRU_SKIP;
> +	}
>  
>  	/*
>  	 * If something else is freeing this dquot and hasn't yet removed it
> @@ -482,7 +485,6 @@ xfs_qm_dquot_isolate(
>  
>  out_miss_unlock:
>  	spin_unlock(&dqp->q_lockref.lock);
> -out_miss_busy:
>  	trace_xfs_dqreclaim_busy(dqp);
>  	XFS_STATS_INC(dqp->q_mount, xs_qm_dqreclaim_misses);
>  	return ret;
> -- 
> 2.47.3
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.