mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yingjie Gao <gaoyingjie@uniontech.com>
To: cem@kernel.org, djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, hch@lst.de,
	Yingjie Gao <gaoyingjie@uniontech.com>
Subject: [PATCH] xfs: retry dqpurge when dquot buffer is busy
Date: Fri, 26 Jun 2026 17:52:53 +0800	[thread overview]
Message-ID: <20260626095253.3445540-1-gaoyingjie@uniontech.com> (raw)

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


             reply	other threads:[~2026-06-26  9:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  9:52 Yingjie Gao [this message]
2026-06-26 20:52 ` Darrick J. Wong
2026-06-29 12:43   ` Christoph Hellwig
2026-06-29 23:49     ` 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=20260626095253.3445540-1-gaoyingjie@uniontech.com \
    --to=gaoyingjie@uniontech.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®