From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org
Cc: stable@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 02/14] xfs: online quotacheck must dirty dquot if enforcement adjustments needed
Date: Tue, 22 Sep 2026 11:02:31 -0700 [thread overview]
Message-ID: <20260922180231.GX2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <178996120594.181988.17443723006471773386.stgit@frogsfrogsfrogs>
On Sun, Sep 20, 2026 at 11:15:30PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> LOLLM noticed that we have no way to force xchk_commit_dquot to call
> xfs_qm_adjust_dqenforcement if nothing else is wrong with the dquot.
> Therefore, add a new predicate to force the dirty flag if the dquot has
> zero limits and there are default limits; or if the grace period timer
> needs adjusting.
>
> 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 | 51 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
>
> diff --git a/fs/xfs/scrub/quotacheck_repair.c b/fs/xfs/scrub/quotacheck_repair.c
> index 48ee08df302a42..e2208510939f08 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)
Shashiko says:
"Does this skip repairing missing grace period timers when the default grace
period is configured to 0?
If a quota usage exceeds its limit but has a missing or corrupt timer
(res->timer == 0) and the default grace period (qlim->time) is 0, this
condition evaluates to false. This causes the repair code to skip dirtying
the dquot, bypassing xfs_qm_adjust_dqenforcement().
When the unfixed dquot is subsequently flushed (e.g., via background
writeback or a log force), xfs_qm_dqflush_check() will find count > softlimit
but timer == 0. This is treated as a fatal inconsistency and triggers
SHUTDOWN_CORRUPT_INCORE, effectively turning a reparable condition into a
denial of service."
Yes, that should just be "if (!res->timer) return true;" since we want
to force xfs_qm_adjust_dqtimers to reset it. I forgot that !qlim->time
just means "expires immediately", not "expires never".
Will fix in next revision.
--D
> + 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) {
>
>
next prev parent reply other threads:[~2026-09-22 18:02 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 6:13 [PATCHSET] xfs: LLM-inspired bug fixes, part 16 Darrick J. Wong
2026-09-21 6:15 ` [PATCH 01/14] xfs: fix missing xfs_qm_adjust_dqlimits call in quotacheck repair Darrick J. Wong
2026-09-22 5:14 ` Christoph Hellwig
2026-09-21 6:15 ` [PATCH 02/14] xfs: online quotacheck must dirty dquot if enforcement adjustments needed Darrick J. Wong
2026-09-22 5:14 ` Christoph Hellwig
2026-09-22 18:02 ` Darrick J. Wong [this message]
2026-09-21 6:15 ` [PATCH 03/14] xfs: fix buffer overruns in xfs_ioc_attr_list Darrick J. Wong
2026-09-22 5:15 ` Christoph Hellwig
2026-09-22 17:31 ` Darrick J. Wong
2026-09-21 6:16 ` [PATCH 04/14] xfs: clean up after failed metafile relinking Darrick J. Wong
2026-09-22 5:17 ` Christoph Hellwig
2026-09-22 17:33 ` Darrick J. Wong
2026-09-21 6:16 ` [PATCH 05/14] xfs: pass xfs_trans_resv object to reservation calculation helpers Darrick J. Wong
2026-09-22 5:18 ` Christoph Hellwig
2026-09-22 17:29 ` Darrick J. Wong
2026-09-22 17:34 ` Darrick J. Wong
2026-09-21 6:16 ` [PATCH 06/14] xfs: fix xfs_rename_space_res for non-pptr filesystems Darrick J. Wong
2026-09-22 5:20 ` Christoph Hellwig
2026-09-22 17:36 ` Darrick J. Wong
2026-09-21 6:16 ` [PATCH 07/14] xfs: fix ondisk symlink target validation in xrep_dinode_check_dfork Darrick J. Wong
2026-09-22 5:20 ` Christoph Hellwig
2026-09-22 20:42 ` Dave Chinner
2026-09-21 6:17 ` [PATCH 08/14] xfs: fix maximum atomic cow length computation Darrick J. Wong
2026-09-22 5:21 ` Christoph Hellwig
2026-09-22 6:53 ` Darrick J. Wong
2026-09-21 6:17 ` [PATCH 09/14] xfs: add missing healthmon trace strings Darrick J. Wong
2026-09-22 5:21 ` Christoph Hellwig
2026-09-21 6:17 ` [PATCH 10/14] xfarray: don't crash when sorting if array element crosses a folio Darrick J. Wong
2026-09-22 5:22 ` Christoph Hellwig
2026-09-22 17:53 ` Darrick J. Wong
2026-09-23 4:39 ` Christoph Hellwig
2026-09-21 6:17 ` [PATCH 11/14] xfarray: don't allow users to unset in the middle of an array Darrick J. Wong
2026-09-22 5:23 ` Christoph Hellwig
2026-09-22 6:47 ` Darrick J. Wong
2026-09-22 18:14 ` Darrick J. Wong
2026-09-21 6:18 ` [PATCH 12/14] xfs: don't allow sorting sparse arrays Darrick J. Wong
2026-09-22 5:24 ` Christoph Hellwig
2026-09-22 18:07 ` Darrick J. Wong
2026-09-21 6:18 ` [PATCH 13/14] xfs: simply the free space btree repair code Darrick J. Wong
2026-09-22 5:24 ` Christoph Hellwig
2026-09-21 6:18 ` [PATCH 14/14] xfarray: warn against sorting arrays with identical elements Darrick J. Wong
2026-09-22 5:25 ` Christoph Hellwig
2026-09-22 18:10 ` 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=20260922180231.GX2705364@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