* [PATCH] xfs: retry dqpurge when dquot buffer is busy
@ 2026-06-26 9:52 Yingjie Gao
2026-06-26 20:52 ` Darrick J. Wong
0 siblings, 1 reply; 4+ messages in thread
From: Yingjie Gao @ 2026-06-26 9:52 UTC (permalink / raw)
To: cem, djwong; +Cc: linux-xfs, linux-kernel, stable, hch, Yingjie Gao
xfs_qm_dqpurge() marks a zero-reference dquot dead before trying to flush
a dirty dquot. If the attached buffer is busy, xfs_dquot_use_attached_buf()
returns -EAGAIN.
The error path restores q_lockref.count but then jumps to out_funlock,
which continues into the successful purge tail and destroys the dquot. At
that point the attached buffer has not been detached and the dquot log item
may still be in the AIL.
Restore the retry behavior by dropping the locks and returning -EAGAIN
after resurrecting the lockref.
Link: https://lore.kernel.org/linux-xfs/20260625175519.GF6078@frogsfrogsfrogs/
Fixes: 0c5e80bd579f ("xfs: use a lockref for the xfs_dquot reference count")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/xfs_qm.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index aa0d2976f1c3..0622c72292d8 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -155,8 +155,12 @@ xfs_qm_dqpurge(
error = xfs_dquot_use_attached_buf(dqp, &bp);
if (error == -EAGAIN) {
/* resurrect the refcount from the dead. */
+ xfs_dqfunlock(dqp);
+ mutex_unlock(&dqp->q_qlock);
+ spin_lock(&dqp->q_lockref.lock);
dqp->q_lockref.count = 0;
- goto out_funlock;
+ spin_unlock(&dqp->q_lockref.lock);
+ return -EAGAIN;
}
if (!bp)
goto out_funlock;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: retry dqpurge when dquot buffer is busy
2026-06-26 9:52 [PATCH] xfs: retry dqpurge when dquot buffer is busy Yingjie Gao
@ 2026-06-26 20:52 ` Darrick J. Wong
2026-06-29 12:43 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-06-26 20:52 UTC (permalink / raw)
To: Yingjie Gao; +Cc: cem, linux-xfs, linux-kernel, stable, hch
On Fri, Jun 26, 2026 at 05:52:53PM +0800, Yingjie Gao wrote:
> xfs_qm_dqpurge() marks a zero-reference dquot dead before trying to flush
> a dirty dquot. If the attached buffer is busy, xfs_dquot_use_attached_buf()
> returns -EAGAIN.
>
> The error path restores q_lockref.count but then jumps to out_funlock,
> which continues into the successful purge tail and destroys the dquot. At
> that point the attached buffer has not been detached and the dquot log item
> may still be in the AIL.
>
> Restore the retry behavior by dropping the locks and returning -EAGAIN
> after resurrecting the lockref.
>
> Link: https://lore.kernel.org/linux-xfs/20260625175519.GF6078@frogsfrogsfrogs/
> Fixes: 0c5e80bd579f ("xfs: use a lockref for the xfs_dquot reference count")
> Cc: stable@vger.kernel.org # v6.19+
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
Yeah, that's more like what we did before 0c5e80bd579f. I think the
lockref resurrection part still looks ok, but maybe hch has an opinion?
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_qm.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index aa0d2976f1c3..0622c72292d8 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -155,8 +155,12 @@ xfs_qm_dqpurge(
> error = xfs_dquot_use_attached_buf(dqp, &bp);
> if (error == -EAGAIN) {
> /* resurrect the refcount from the dead. */
> + xfs_dqfunlock(dqp);
> + mutex_unlock(&dqp->q_qlock);
> + spin_lock(&dqp->q_lockref.lock);
> dqp->q_lockref.count = 0;
> - goto out_funlock;
> + spin_unlock(&dqp->q_lockref.lock);
> + return -EAGAIN;
> }
> if (!bp)
> goto out_funlock;
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: retry dqpurge when dquot buffer is busy
2026-06-26 20:52 ` Darrick J. Wong
@ 2026-06-29 12:43 ` Christoph Hellwig
2026-06-29 23:49 ` Darrick J. Wong
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-06-29 12:43 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Yingjie Gao, cem, linux-xfs, linux-kernel, stable, hch
On Fri, Jun 26, 2026 at 01:52:57PM -0700, Darrick J. Wong wrote:
> On Fri, Jun 26, 2026 at 05:52:53PM +0800, Yingjie Gao wrote:
> > xfs_qm_dqpurge() marks a zero-reference dquot dead before trying to flush
> > a dirty dquot. If the attached buffer is busy, xfs_dquot_use_attached_buf()
> > returns -EAGAIN.
> >
> > The error path restores q_lockref.count but then jumps to out_funlock,
> > which continues into the successful purge tail and destroys the dquot. At
> > that point the attached buffer has not been detached and the dquot log item
> > may still be in the AIL.
> >
> > Restore the retry behavior by dropping the locks and returning -EAGAIN
> > after resurrecting the lockref.
> >
> > Link: https://lore.kernel.org/linux-xfs/20260625175519.GF6078@frogsfrogsfrogs/
> > Fixes: 0c5e80bd579f ("xfs: use a lockref for the xfs_dquot reference count")
> > Cc: stable@vger.kernel.org # v6.19+
> > Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
>
> Yeah, that's more like what we did before 0c5e80bd579f. I think the
> lockref resurrection part still looks ok, but maybe hch has an opinion?
But is it the right thing? In dqpurge we really want to kill of the
dquot, so doing a trylock is not very useful, so we really should not
do a trylock here but just lock the buffer.
Darrick, do you remember if there's any lock order inversions we need
to care about here?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: retry dqpurge when dquot buffer is busy
2026-06-29 12:43 ` Christoph Hellwig
@ 2026-06-29 23:49 ` Darrick J. Wong
0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2026-06-29 23:49 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Yingjie Gao, cem, linux-xfs, linux-kernel, stable
On Mon, Jun 29, 2026 at 02:43:56PM +0200, Christoph Hellwig wrote:
> On Fri, Jun 26, 2026 at 01:52:57PM -0700, Darrick J. Wong wrote:
> > On Fri, Jun 26, 2026 at 05:52:53PM +0800, Yingjie Gao wrote:
> > > xfs_qm_dqpurge() marks a zero-reference dquot dead before trying to flush
> > > a dirty dquot. If the attached buffer is busy, xfs_dquot_use_attached_buf()
> > > returns -EAGAIN.
> > >
> > > The error path restores q_lockref.count but then jumps to out_funlock,
> > > which continues into the successful purge tail and destroys the dquot. At
> > > that point the attached buffer has not been detached and the dquot log item
> > > may still be in the AIL.
> > >
> > > Restore the retry behavior by dropping the locks and returning -EAGAIN
> > > after resurrecting the lockref.
> > >
> > > Link: https://lore.kernel.org/linux-xfs/20260625175519.GF6078@frogsfrogsfrogs/
> > > Fixes: 0c5e80bd579f ("xfs: use a lockref for the xfs_dquot reference count")
> > > Cc: stable@vger.kernel.org # v6.19+
> > > Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
> >
> > Yeah, that's more like what we did before 0c5e80bd579f. I think the
> > lockref resurrection part still looks ok, but maybe hch has an opinion?
>
> But is it the right thing? In dqpurge we really want to kill of the
> dquot, so doing a trylock is not very useful, so we really should not
> do a trylock here but just lock the buffer.
>
> Darrick, do you remember if there's any lock order inversions we need
> to care about here?
I don't remember off the top of my head, other than (afaict) the trylock
might be a remnant of not wanting to block in quotaoff purge while the
QUOTAOFF log item is also pinning the log tail.
--D
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-29 23:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 9:52 [PATCH] xfs: retry dqpurge when dquot buffer is busy Yingjie Gao
2026-06-26 20:52 ` Darrick J. Wong
2026-06-29 12:43 ` Christoph Hellwig
2026-06-29 23:49 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox