* [PATCH 1/6] xfs: cross-reference the rtgroup superblock extent, not block
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
@ 2026-09-03 5:51 ` Darrick J. Wong
2026-09-03 6:04 ` Christoph Hellwig
2026-09-03 5:51 ` [PATCH 2/6] xfs: use the rtgroup extent count to find rtrefcount gaps Darrick J. Wong
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2026-09-03 5:51 UTC (permalink / raw)
To: hch, cem, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM noticed that when libxfs creates a realtime superblock, it will
create an rtrmapbt record covering the entire rtextent in which the
superblock lives. However, the cross-referencing checks only look for
the first block, which means that we can miss a corrupt rtrmap record.
That will get picked up by the rtrmap scrubber, but we should make the
rgsuper scrubber more robust anyway.
Cc: <stable@vger.kernel.org> # v6.13
Fixes: 3f1bdf50ab1b9c ("xfs: scrub the realtime group superblock")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/scrub/rgsuper.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/scrub/rgsuper.c b/fs/xfs/scrub/rgsuper.c
index 2bd2c0351b35f7..6e2abe5dc27cd5 100644
--- a/fs/xfs/scrub/rgsuper.c
+++ b/fs/xfs/scrub/rgsuper.c
@@ -36,8 +36,10 @@ xchk_rgsuperblock_xref(
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return;
- xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1);
- xchk_xref_is_only_rt_owned_by(sc, 0, 1, &XFS_RMAP_OINFO_FS);
+ xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0),
+ sc->mp->m_sb.sb_rextsize);
+ xchk_xref_is_only_rt_owned_by(sc, 0, sc->mp->m_sb.sb_rextsize,
+ &XFS_RMAP_OINFO_FS);
}
int
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/6] xfs: cross-reference the rtgroup superblock extent, not block
2026-09-03 5:51 ` [PATCH 1/6] xfs: cross-reference the rtgroup superblock extent, not block Darrick J. Wong
@ 2026-09-03 6:04 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2026-09-03 6:04 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: hch, cem, stable, linux-xfs
On Wed, Sep 02, 2026 at 10:51:05PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> LOLLM noticed that when libxfs creates a realtime superblock, it will
> create an rtrmapbt record covering the entire rtextent in which the
> superblock lives. However, the cross-referencing checks only look for
> the first block, which means that we can miss a corrupt rtrmap record.
> That will get picked up by the rtrmap scrubber, but we should make the
> rgsuper scrubber more robust anyway.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/6] xfs: use the rtgroup extent count to find rtrefcount gaps
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
2026-09-03 5:51 ` [PATCH 1/6] xfs: cross-reference the rtgroup superblock extent, not block Darrick J. Wong
@ 2026-09-03 5:51 ` Darrick J. Wong
2026-09-03 6:07 ` Christoph Hellwig
2026-09-03 5:51 ` [PATCH 3/6] xfs: strengthen the "is cow staging" helpers in scrub Darrick J. Wong
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2026-09-03 5:51 UTC (permalink / raw)
To: hch, cem, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM noticed an anachronism from the early days of rtrefcount where the
refcount btree would handle 64-bit block numbers -- we pass rtblocks
into the gap finder, but rtrefcount btrees are sharded by rtgroup now.
This isn't really a problem for us since we're only looking for
overlapping rtrmap records to flag, but let's fix this sillyness.
Also fix some stale comments.
Cc: <stable@vger.kernel.org> # v6.14
Fixes: 30f47950dc2eba ("xfs: check reference counts of gaps between rt refcount records")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/scrub/rtrefcount.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/scrub/rtrefcount.c b/fs/xfs/scrub/rtrefcount.c
index de100178f41c70..a024d50cf9d20f 100644
--- a/fs/xfs/scrub/rtrefcount.c
+++ b/fs/xfs/scrub/rtrefcount.c
@@ -428,7 +428,7 @@ static inline void
xchk_rtrefcountbt_xref_gaps(
struct xfs_scrub *sc,
struct xchk_rtrefcbt_records *rrc,
- xfs_rtblock_t bno)
+ xfs_rgblock_t bno)
{
struct xfs_rmap_irec low;
struct xfs_rmap_irec high;
@@ -538,7 +538,7 @@ xchk_refcount_xref_rmap(
xchk_btree_xref_set_corrupt(sc, sc->sr.rmap_cur, 0);
}
-/* Scrub the refcount btree for some AG. */
+/* Scrub the refcount btree for some rtgroup. */
int
xchk_rtrefcountbt(
struct xfs_scrub *sc)
@@ -564,10 +564,10 @@ xchk_rtrefcountbt(
/*
* Check that all blocks between the last refcount > 1 record and the
- * end of the rt volume have at most one reverse mapping.
+ * end of the rtgroup have at most one reverse mapping.
*/
- xchk_rtrefcountbt_xref_gaps(sc, &rrc, sc->mp->m_sb.sb_rblocks);
-
+ xchk_rtrefcountbt_xref_gaps(sc, &rrc,
+ xfs_rtx_to_rgbno(sc->sr.rtg, sc->mp->m_sb.sb_rgextents));
xchk_refcount_xref_rmap(sc, &btree_oinfo, rrc.cow_blocks);
return 0;
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 3/6] xfs: strengthen the "is cow staging" helpers in scrub
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
2026-09-03 5:51 ` [PATCH 1/6] xfs: cross-reference the rtgroup superblock extent, not block Darrick J. Wong
2026-09-03 5:51 ` [PATCH 2/6] xfs: use the rtgroup extent count to find rtrefcount gaps Darrick J. Wong
@ 2026-09-03 5:51 ` Darrick J. Wong
2026-09-03 6:08 ` Christoph Hellwig
2026-09-03 5:51 ` [PATCH 4/6] xfs: fix rtrefcount btree block counting " Darrick J. Wong
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2026-09-03 5:51 UTC (permalink / raw)
To: hch, cem, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM pointed out a bug in both of the refcount scrub predicates that
determine if a range of blocks is marked as CoW staging in the btree.
While it compares blockcount < len, this isn't enough to determine that
the CoW staging record is at least as large as the range passed into the
helper. Fix both of them.
Cc: <stable@vger.kernel.org> # v4.16
Fixes: f6d5fc21fdc713 ("xfs: cross-reference refcount btree during scrub")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/scrub/refcount.c | 6 +++++-
fs/xfs/scrub/rtrefcount.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
index f2addaf13c58e4..f8c51d8fbb3da5 100644
--- a/fs/xfs/scrub/refcount.c
+++ b/fs/xfs/scrub/refcount.c
@@ -581,8 +581,12 @@ xchk_xref_is_cow_staging(
if (rc.rc_domain != XFS_REFC_DOMAIN_COW)
xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0);
+ /* Can't start after bno */
+ if (rc.rc_startblock > agbno)
+ xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0);
+
/* Must be at least as long as what was passed in */
- if (rc.rc_blockcount < len)
+ if (rc.rc_startblock + rc.rc_blockcount < agbno + len)
xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0);
}
diff --git a/fs/xfs/scrub/rtrefcount.c b/fs/xfs/scrub/rtrefcount.c
index a024d50cf9d20f..652d6b78b7a05b 100644
--- a/fs/xfs/scrub/rtrefcount.c
+++ b/fs/xfs/scrub/rtrefcount.c
@@ -609,8 +609,12 @@ xchk_xref_is_rt_cow_staging(
if (rc.rc_domain != XFS_REFC_DOMAIN_COW)
xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0);
+ /* Can't start after bno */
+ if (rc.rc_startblock > bno)
+ xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0);
+
/* Must be at least as long as what was passed in */
- if (rc.rc_blockcount < len)
+ if (rc.rc_startblock + rc.rc_blockcount < bno + len)
xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0);
}
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 4/6] xfs: fix rtrefcount btree block counting in scrub
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
` (2 preceding siblings ...)
2026-09-03 5:51 ` [PATCH 3/6] xfs: strengthen the "is cow staging" helpers in scrub Darrick J. Wong
@ 2026-09-03 5:51 ` Darrick J. Wong
2026-09-03 6:10 ` Christoph Hellwig
2026-09-03 5:52 ` [PATCH 5/6] xfs: make the rtsummary repair fix the file size too Darrick J. Wong
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2026-09-03 5:51 UTC (permalink / raw)
To: hch, cem, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM started on a long tangent about how xchk_refcount_xref_rmap
shouldn't nope out if sc->sa.rmap_cur isn't set, because nothing ever
sets that field. It's right about the condition, but misses the bigger
problem, which is that to count the rtrefcount btree blocks, we have to
walk all rmap records in each AG in the data section. That was papered
over by the incorrect !sc->sa.rmap_cur test.
In other words, we need a perag iteration loop here. Restructure the
code to do that, and now it'll all work properly. Fix the confusing
function name prefix.
Cc: <stable@vger.kernel.org> # v6.14
Fixes: c27929670de144 ("xfs: scrub the realtime refcount btree")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/scrub/rtrefcount.c | 64 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 55 insertions(+), 9 deletions(-)
diff --git a/fs/xfs/scrub/rtrefcount.c b/fs/xfs/scrub/rtrefcount.c
index 652d6b78b7a05b..3d916d71a135dc 100644
--- a/fs/xfs/scrub/rtrefcount.c
+++ b/fs/xfs/scrub/rtrefcount.c
@@ -20,6 +20,7 @@
#include "xfs_metafile.h"
#include "xfs_rtrefcount_btree.h"
#include "xfs_rtalloc.h"
+#include "xfs_ag.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/btree.h"
@@ -504,30 +505,75 @@ xchk_rtrefcountbt_rec(
return 0;
}
+/* Count the number of blocks used by the rtrefcount btree file in this AG. */
+static int
+xchk_rtrefcount_count_agblocks(
+ struct xfs_scrub *sc,
+ xfs_agnumber_t agno,
+ const struct xfs_owner_info *btree_oinfo,
+ xfs_filblks_t *blocks)
+{
+ xfs_filblks_t agblocks = 0;
+ int error;
+
+ error = xchk_ag_init_existing(sc, agno, &sc->sa);
+ if (error)
+ goto out_free;
+
+ /*
+ * If we don't have an rmap cursor, we can't complete the cross
+ * referencing, so return EFSCORRUPTED to end the loop and trigger the
+ * XFAIL flag.
+ */
+ if (!sc->sa.rmap_cur) {
+ error = -EFSCORRUPTED;
+ goto out_free;
+ }
+
+ error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, btree_oinfo,
+ &agblocks);
+ if (error)
+ goto out_free;
+
+ *blocks += agblocks;
+out_free:
+ xchk_ag_free(sc, &sc->sa);
+ return error;
+}
+
/* Make sure we have as many refc blocks as the rmap says. */
STATIC void
-xchk_refcount_xref_rmap(
+xchk_rtrefcount_xref_rmap(
struct xfs_scrub *sc,
const struct xfs_owner_info *btree_oinfo,
xfs_extlen_t cow_blocks)
{
xfs_filblks_t refcbt_blocks = 0;
- xfs_filblks_t blocks;
- int error;
+ xfs_filblks_t blocks = 1; /* one for the iroot */
+ xfs_agnumber_t agno;
+ int error = 0;
- if (!sc->sr.rmap_cur || !sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
+ if (!xfs_has_rmapbt(sc->mp) || xchk_skip_xref(sc->sm))
return;
/* Check that we saw as many refcbt blocks as the rmap knows about. */
error = xfs_btree_count_blocks(sc->sr.refc_cur, &refcbt_blocks);
if (!xchk_btree_process_error(sc, sc->sr.refc_cur, 0, &error))
return;
- error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, btree_oinfo,
- &blocks);
- if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur))
+
+ for (agno = 0; agno < sc->mp->m_sb.sb_agcount; agno++) {
+ error = xchk_rtrefcount_count_agblocks(sc, agno, btree_oinfo,
+ &blocks);
+ if (error)
+ break;
+ }
+ if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error))
return;
if (blocks != refcbt_blocks)
- xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0);
+ xchk_fblock_xref_set_corrupt(sc, XFS_DATA_FORK, 0);
+
+ if (!sc->sr.rmap_cur || xchk_skip_xref(sc->sm))
+ return;
/* Check that we saw as many cow blocks as the rmap knows about. */
error = xchk_count_rmap_ownedby_ag(sc, sc->sr.rmap_cur,
@@ -568,7 +614,7 @@ xchk_rtrefcountbt(
*/
xchk_rtrefcountbt_xref_gaps(sc, &rrc,
xfs_rtx_to_rgbno(sc->sr.rtg, sc->mp->m_sb.sb_rgextents));
- xchk_refcount_xref_rmap(sc, &btree_oinfo, rrc.cow_blocks);
+ xchk_rtrefcount_xref_rmap(sc, &btree_oinfo, rrc.cow_blocks);
return 0;
}
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 4/6] xfs: fix rtrefcount btree block counting in scrub
2026-09-03 5:51 ` [PATCH 4/6] xfs: fix rtrefcount btree block counting " Darrick J. Wong
@ 2026-09-03 6:10 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2026-09-03 6:10 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: hch, cem, stable, linux-xfs
On Wed, Sep 02, 2026 at 10:51:52PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> LOLLM started on a long tangent about how xchk_refcount_xref_rmap
> shouldn't nope out if sc->sa.rmap_cur isn't set, because nothing ever
> sets that field. It's right about the condition, but misses the bigger
> problem,
I see a pattern there :)
> which is that to count the rtrefcount btree blocks, we have to
> walk all rmap records in each AG in the data section. That was papered
> over by the incorrect !sc->sa.rmap_cur test.
>
> In other words, we need a perag iteration loop here. Restructure the
> code to do that, and now it'll all work properly. Fix the confusing
> function name prefix.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 5/6] xfs: make the rtsummary repair fix the file size too
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
` (3 preceding siblings ...)
2026-09-03 5:51 ` [PATCH 4/6] xfs: fix rtrefcount btree block counting " Darrick J. Wong
@ 2026-09-03 5:52 ` Darrick J. Wong
2026-09-03 6:11 ` Christoph Hellwig
2026-09-03 5:52 ` [PATCH 6/6] xfs: count escaped corruption errors in scrub stats Darrick J. Wong
2026-09-07 6:29 ` [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Carlos Maiolino
6 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2026-09-03 5:52 UTC (permalink / raw)
To: hch, cem, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM noticed that the rtsummary repair code will create a new rtsummary
with the correct file size, but it won't force the new file size to be
set on the existing rtsummary file, leaving the rtsummary corrupt. Fix
this by setting up the tempfile mapping-exchange to run to the end of
both files, which is the magic offset needed to reset the file size.
Cc: <stable@vger.kernel.org> # v6.10
Fixes: abf039e2e4afde ("xfs: online repair of realtime summaries")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/scrub/rtsummary_repair.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/scrub/rtsummary_repair.c b/fs/xfs/scrub/rtsummary_repair.c
index f065c3e51ce2e4..ed763290aec1e5 100644
--- a/fs/xfs/scrub/rtsummary_repair.c
+++ b/fs/xfs/scrub/rtsummary_repair.c
@@ -164,9 +164,10 @@ xrep_rtsummary(
/*
* Now exchange the contents. Nothing in repair uses the temporary
* buffer, so we can reuse it for the tempfile exchrange information.
+ * Use XFS_MAX_FILEOFF here so that we correct the rtsummary file size.
*/
error = xrep_tempexch_trans_reserve(sc, XFS_DATA_FORK, 0,
- rts->rsumblocks, &rts->tempexch);
+ XFS_MAX_FILEOFF, &rts->tempexch);
if (error)
return error;
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 5/6] xfs: make the rtsummary repair fix the file size too
2026-09-03 5:52 ` [PATCH 5/6] xfs: make the rtsummary repair fix the file size too Darrick J. Wong
@ 2026-09-03 6:11 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2026-09-03 6:11 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: hch, cem, stable, linux-xfs
On Wed, Sep 02, 2026 at 10:52:07PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> LOLLM noticed that the rtsummary repair code will create a new rtsummary
> with the correct file size, but it won't force the new file size to be
> set on the existing rtsummary file, leaving the rtsummary corrupt. Fix
> this by setting up the tempfile mapping-exchange to run to the end of
> both files, which is the magic offset needed to reset the file size.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/6] xfs: count escaped corruption errors in scrub stats
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
` (4 preceding siblings ...)
2026-09-03 5:52 ` [PATCH 5/6] xfs: make the rtsummary repair fix the file size too Darrick J. Wong
@ 2026-09-03 5:52 ` Darrick J. Wong
2026-09-03 6:11 ` Christoph Hellwig
2026-09-07 6:29 ` [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Carlos Maiolino
6 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2026-09-03 5:52 UTC (permalink / raw)
To: hch, cem, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
The main scrub code will quietly turn bubbled-up EFSCORRUPTED and
EFSBADCRC errors into corruption errors. These aren't recorded in the
scrub stats code (says LOLLM) so do that now.
Cc: <stable@vger.kernel.org> # v6.6
Fixes: d7a74cad8f4513 ("xfs: track usage statistics of online fsck")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/scrub/stats.h | 4 ++--
fs/xfs/scrub/scrub.c | 3 +--
fs/xfs/scrub/stats.c | 28 +++++++++++++++++++---------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/fs/xfs/scrub/stats.h b/fs/xfs/scrub/stats.h
index b358ad8d8b90ac..221052b95dd077 100644
--- a/fs/xfs/scrub/stats.h
+++ b/fs/xfs/scrub/stats.h
@@ -27,7 +27,7 @@ void xchk_stats_register(struct xchk_stats *cs, struct dentry *parent);
void xchk_stats_unregister(struct xchk_stats *cs);
void xchk_stats_merge(struct xfs_mount *mp, const struct xfs_scrub_metadata *sm,
- const struct xchk_stats_run *run);
+ int error, const struct xchk_stats_run *run);
static inline u64 xchk_stats_now(void) { return ktime_get_ns(); }
static inline u64 xchk_stats_elapsed_ns(u64 since)
@@ -53,7 +53,7 @@ static inline u64 xchk_stats_elapsed_ns(u64 since)
# define xchk_stats_unregister(cs) ((void)0)
# define xchk_stats_now() (0)
# define xchk_stats_elapsed_ns(x) (0 * (x))
-# define xchk_stats_merge(mp, sm, run) ((void)0)
+# define xchk_stats_merge(mp, sm, error, run) ((void)0)
#endif /* CONFIG_XFS_ONLINE_SCRUB_STATS */
#endif /* __XFS_SCRUB_STATS_H__ */
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index 8742445c86f45e..12c228b7f4770d 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -765,8 +765,7 @@ xfs_scrub_metadata(
out_teardown:
error = xchk_teardown(sc, error);
out_sc:
- if (error != -ENOENT)
- xchk_stats_merge(mp, sm, &run);
+ xchk_stats_merge(mp, sm, error, &run);
kfree(sc);
out:
trace_xchk_done(XFS_I(file_inode(file)), sm, error);
diff --git a/fs/xfs/scrub/stats.c b/fs/xfs/scrub/stats.c
index ef3f6abdb7061a..76f2515188d1b1 100644
--- a/fs/xfs/scrub/stats.c
+++ b/fs/xfs/scrub/stats.c
@@ -188,31 +188,37 @@ STATIC void
xchk_stats_merge_one(
struct xchk_stats *cs,
const struct xfs_scrub_metadata *sm,
+ int error,
const struct xchk_stats_run *run)
{
struct xchk_scrub_stats *css;
+ unsigned int sm_flags = sm->sm_flags;
if (sm->sm_type >= XFS_SCRUB_TYPE_NR) {
ASSERT(sm->sm_type < XFS_SCRUB_TYPE_NR);
return;
}
+ /* caller applies this same transformation after we return */
+ if (error == -EFSCORRUPTED || error == -EFSBADCRC)
+ sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
+
css = &cs->cs_stats[sm->sm_type];
spin_lock(&css->css_lock);
css->invocations++;
- if (!(sm->sm_flags & XFS_SCRUB_OFLAG_UNCLEAN))
+ if (!(sm_flags & XFS_SCRUB_OFLAG_UNCLEAN))
css->clean++;
- if (sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
+ if (sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
css->corrupt++;
- if (sm->sm_flags & XFS_SCRUB_OFLAG_PREEN)
+ if (sm_flags & XFS_SCRUB_OFLAG_PREEN)
css->preen++;
- if (sm->sm_flags & XFS_SCRUB_OFLAG_XFAIL)
+ if (sm_flags & XFS_SCRUB_OFLAG_XFAIL)
css->xfail++;
- if (sm->sm_flags & XFS_SCRUB_OFLAG_XCORRUPT)
+ if (sm_flags & XFS_SCRUB_OFLAG_XCORRUPT)
css->xcorrupt++;
- if (sm->sm_flags & XFS_SCRUB_OFLAG_INCOMPLETE)
+ if (sm_flags & XFS_SCRUB_OFLAG_INCOMPLETE)
css->incomplete++;
- if (sm->sm_flags & XFS_SCRUB_OFLAG_WARNING)
+ if (sm_flags & XFS_SCRUB_OFLAG_WARNING)
css->warning++;
css->retries += run->retries;
css->checktime_us += howmany_64(run->scrub_ns, NSEC_PER_USEC);
@@ -230,10 +236,14 @@ void
xchk_stats_merge(
struct xfs_mount *mp,
const struct xfs_scrub_metadata *sm,
+ int error,
const struct xchk_stats_run *run)
{
- xchk_stats_merge_one(&global_stats, sm, run);
- xchk_stats_merge_one(mp->m_scrub_stats, sm, run);
+ if (error == -ENOENT)
+ return;
+
+ xchk_stats_merge_one(&global_stats, sm, error, run);
+ xchk_stats_merge_one(mp->m_scrub_stats, sm, error, run);
}
/* debugfs boilerplate */
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCHSET] xfs: LLM-inspired bug fixes, part 10
2026-09-03 5:51 [PATCHSET] xfs: LLM-inspired bug fixes, part 10 Darrick J. Wong
` (5 preceding siblings ...)
2026-09-03 5:52 ` [PATCH 6/6] xfs: count escaped corruption errors in scrub stats Darrick J. Wong
@ 2026-09-07 6:29 ` Carlos Maiolino
6 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2026-09-07 6:29 UTC (permalink / raw)
To: hch, Darrick J. Wong; +Cc: stable, linux-xfs
On Wed, 02 Sep 2026 22:51:00 -0700, Darrick J. Wong wrote:
> Here's a tenth batch of xfs fixes resulting from a LLaMma. Mwa mwa
> mwa...
>
> If you're going to start using this code, I strongly recommend pulling
> from my git trees, which are linked below.
>
> With a bit of luck, this should all go splendidly.
> Comments and questions are, as always, welcome.
>
> [...]
Applied to for-next, thanks!
[1/6] xfs: cross-reference the rtgroup superblock extent, not block
commit: 79ab1af2034b2ad10c5f18910937b938d2ad2219
[2/6] xfs: use the rtgroup extent count to find rtrefcount gaps
commit: c3085f6c7cca7c162248519ce8d763047cdd8acd
[3/6] xfs: strengthen the "is cow staging" helpers in scrub
commit: 0d43368844a75ad13561a1198a3b027940730756
[4/6] xfs: fix rtrefcount btree block counting in scrub
commit: 3f9fd694fa429e89fe6de51b22b0ed5fb8b2daf4
[5/6] xfs: make the rtsummary repair fix the file size too
commit: 6b760b3232b3efc8bcc7c165e76300bc1c9140c5
[6/6] xfs: count escaped corruption errors in scrub stats
commit: 4d0624679ae29b469016f1ce4714be58582ed06a
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 14+ messages in thread