Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, cem@kernel.org
Cc: stable@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 01/11] xfs: always call xfs_qm_adjust_dqlimits during quotacheck repair
Date: Mon, 14 Sep 2026 22:36:49 -0700	[thread overview]
Message-ID: <178945048522.3061055.5283654279910692050.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <178945048435.3061055.16384804993810925544.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

LOLLM notices that everywhere else in the kernel, a call to
xfs_qm_adjust_dqlimits precedes every call to xfs_qm_adjust_dqtimers.
In particular, mount-time quotacheck does this.

Looking at xfs_qm_adjust_dqlimits, that function is in charge of
conveying default limits to a dquot if that dquot's limits have been
zeroed.  That's quite possible in a repair, so let's follow what
everyone else does and set it.  This requires us to add a new predicate
to decide if xfs_qm_adjust_dqlimits is likely to reset any of the
dquot's limits, and to set the dirty flag to true if so.

A different LOLLM noticed that we have no way to force xchk_commit_dquot
to call xfs_qm_adjust_dqtimers, so pack that in at the same time.

Cc: <stable@vger.kernel.org> # v6.9
Fixes: 96ed2ae4a9b06b ("xfs: repair dquots based on live quotacheck results")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
 fs/xfs/scrub/quotacheck_repair.c |   55 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)


diff --git a/fs/xfs/scrub/quotacheck_repair.c b/fs/xfs/scrub/quotacheck_repair.c
index dbb522e1513b0b..c35982ba2e1721 100644
--- a/fs/xfs/scrub/quotacheck_repair.c
+++ b/fs/xfs/scrub/quotacheck_repair.c
@@ -39,6 +39,54 @@
  * dquot is locked.
  */
 
+static bool
+xqcheck_dqres_force_dirty(
+	const struct xfs_dquot_res	*res,
+	const struct xfs_quota_limits	*qlim)
+{
+	/* zero limits mean that we should set the default limits */
+	if (res->softlimit == 0 && qlim->soft != 0)
+		return true;
+	if (res->hardlimit == 0 && qlim->hard != 0)
+		return true;
+
+	/* do we need to adjust the timer setting? */
+	if ((res->softlimit && res->count > res->softlimit) ||
+	    (res->hardlimit && res->count > res->hardlimit)) {
+		if (res->timer == 0 && qlim->time != 0)
+			return true;
+	} else {
+		if (res->timer)
+			return true;
+	}
+
+	return false;
+}
+
+/* Decide if we need to adjust the dquot limits or timers */
+static bool
+xqcheck_dquot_force_dirty(
+	const struct xfs_dquot	*dq)
+{
+	struct xfs_quotainfo	*qi = dq->q_mount->m_quotainfo;
+	struct xfs_def_quota	*defq;
+
+	/* root dquot does not enforce limits */
+	if (dq->q_id == 0)
+		return false;
+
+	defq = xfs_get_defquota(qi, xfs_dquot_type(dq));
+
+	if (xqcheck_dqres_force_dirty(&dq->q_blk, &defq->blk))
+		return true;
+	if (xqcheck_dqres_force_dirty(&dq->q_ino, &defq->ino))
+		return true;
+	if (xqcheck_dqres_force_dirty(&dq->q_rtb, &defq->rtb))
+		return true;
+
+	return false;
+}
+
 /* Commit new counters to a dquot. */
 static int
 xqcheck_commit_dquot(
@@ -91,6 +139,9 @@ xqcheck_commit_dquot(
 		dirty = true;
 	}
 
+	if (!dirty && xqcheck_dquot_force_dirty(dq))
+		dirty = true;
+
 	xcdq.flags |= (XQCHECK_DQUOT_REPAIR_SCANNED | XQCHECK_DQUOT_WRITTEN);
 	error = xfarray_store(counts, dq->q_id, &xcdq);
 	if (error == -EFBIG) {
@@ -110,8 +161,10 @@ xqcheck_commit_dquot(
 
 	/* Commit the dirty dquot to disk. */
 	dq->q_flags |= XFS_DQFLAG_DIRTY;
-	if (dq->q_id)
+	if (dq->q_id) {
+		xfs_qm_adjust_dqlimits(dq);
 		xfs_qm_adjust_dqtimers(dq);
+	}
 	xfs_trans_log_dquot(xqc->sc->tp, dq);
 	return xrep_trans_commit(xqc->sc);
 


  reply	other threads:[~2026-09-15  5:36 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15  5:36 [PATCHSET] xfs: LLM-inspired bug fixes, part 15 Darrick J. Wong
2026-09-15  5:36 ` Darrick J. Wong [this message]
2026-09-15  6:25   ` [PATCH 01/11] xfs: always call xfs_qm_adjust_dqlimits during quotacheck repair Christoph Hellwig
2026-09-15 17:38     ` Darrick J. Wong
2026-09-15 20:04       ` Carlos Maiolino
2026-09-15  5:37 ` [PATCH 02/11] xfs: call xfs_dquot_set_prealloc_limits if we installed default rtb limits Darrick J. Wong
2026-09-15  6:26   ` Christoph Hellwig
2026-09-15  5:37 ` [PATCH 03/11] xfs: fix rtgroup repair estimations Darrick J. Wong
2026-09-15  6:26   ` Christoph Hellwig
2026-09-15  5:37 ` [PATCH 04/11] xfs: don't cross reference rmapbt with bitmaps if they're incomplete Darrick J. Wong
2026-09-15  6:29   ` Christoph Hellwig
2026-09-15  5:37 ` [PATCH 05/11] xfs: don't let memory failures leak blocks and kill repairs Darrick J. Wong
2026-09-15  6:30   ` Christoph Hellwig
2026-09-15  5:38 ` [PATCH 06/11] xfs: don't merge different file IO error types Darrick J. Wong
2026-09-15  6:30   ` Christoph Hellwig
2026-09-15  5:38 ` [PATCH 07/11] xfs: fix blockgc group quota scanning when usrquota isn't enforced Darrick J. Wong
2026-09-15  6:31   ` Christoph Hellwig
2026-09-15  5:38 ` [PATCH 08/11] xfs: fix cursor and pointer handling when recovering iunlink buckets Darrick J. Wong
2026-09-15  6:31   ` Christoph Hellwig
2026-09-15  5:38 ` [PATCH 09/11] xfs: drop dquot flush lock when we can't find a buffer to flush Darrick J. Wong
2026-09-15  6:32   ` Christoph Hellwig
2026-09-15  5:39 ` [PATCH 10/11] xfs: don't let hidden_space go negative in xfs_metafile_resv_init Darrick J. Wong
2026-09-15  6:32   ` Christoph Hellwig
2026-09-15  5:39 ` [PATCH 11/11] xfs: fix wild memcpy access when formatting ondisk rtrefcount btree roots Darrick J. Wong
2026-09-15  6:33   ` Christoph Hellwig
2026-09-16 12:06 ` [PATCHSET] xfs: LLM-inspired bug fixes, part 15 Carlos Maiolino

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=178945048522.3061055.5283654279910692050.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@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