Skip to content

feat(xfs): add Linux 7.0 XFS statistics fields - #810

Merged
SuperQ merged 2 commits into
prometheus:masterfrom
dongjiang1989:updata-xfs-for-7.0
Jun 21, 2026
Merged

SuperQ merged 2 commits into
prometheus:masterfrom
dongjiang1989:updata-xfs-for-7.0

Conversation

@dongjiang1989

Copy link
Copy Markdown
Member

ref: https://elixir.bootlin.com/linux/v7.0/source/fs/xfs/xfs_stats.c

Summary

  • Update XFS statistics parsing to match the Linux 7.0 kernel (fs/xfs/xfs_stats.c)
  • Add support for 9 new btree stat groups: fibt2, rmapbt, refcntbt, rmapbt_mem, rcbagbt, rtrmapbt, rtrmapbt_mem, rtrefcntbt, rtrefcntbt — each with 15
    counters (lookup, compare, insrec, delrec, newroot, killroot, increment, decrement, lshift, rshift, split, join, alloc, free, moves)
  • Add 2 new stat groups: zoned (gc_read_calls, gc_bytes) and metafile (inodes, meta)
  • Add defer_relog (uint64) and gc xpc (uint64) extended precision counters
  • Add trailing comments with proc label names to all Stats struct fields for easier reference
  • Update test fixtures (proc and sys) to include all new fields
  • Add unit tests for all new stat groups (happy path + invalid count cases)

Test plan

  • go vet ./xfs/... passes
  • go test ./xfs/... passes (TestParseStats, TestReadProcStat, TestReadSysStats)
  • New inline tests cover bad/good cases for: fibt2, rmapbt, refcntbt, rmapbt_mem, rcbagbt, rtrmapbt, rtrmapbt_mem, rtrefcntbt, zoned, metafile, defer_relog, gc xpc

@dongjiang1989

Copy link
Copy Markdown
Member Author

Hi @SuperQ , PTAL, thanks.

@dongjiang1989

Copy link
Copy Markdown
Member Author

@discordianfish, @SuperQ Hi, I would appreciate your review of this PR. Thank you.

@stanhu

stanhu commented May 22, 2026

Copy link
Copy Markdown

@SuperQ Hope you are well. It looks like we received a bug report around this as well in https://gitlab.com/gitlab-org/omnibus-gitlab/-/work_items/9876.

@DragonWork

Copy link
Copy Markdown
Contributor

@dongjiang1989 I just tested your PR. Thanks!

It does need some further adjustments though, I get this error with Linux 7.0.7:

level=ERROR source=collector.go:168 msg="collector failed" name=xfs duration_seconds=0.000168223 err="failed to retrieve XFS stats: incorrect number of values for zoned stats: 3"
# cat /sys/fs/xfs/stats/stats
extent_alloc 4841 1382197 3198 1341523
abt 0 0 0 0
blk_map 2115317 2567929 18137 12841 12363 5130917 0
bmbt 0 0 0 0
dir 669509 14982 13231 155344
trans 1 184826 0
ig 656660 133557 0 523103 0 269933 8926
log 6444 80186 36 6343 5938
push_ail 187025 0 123178 16362 0 2882 1133 318 0 318
xstrat 4612 0
rw 2516859 5862583
attr 43947 21 23 2446
icluster 0 6036 18228
vnodes 253170 0 0 0 278269 278269 278269 0
buf 2879784 35660 2844127 2677019 2487 35657 10 0 35347
abtb2 13643 138539 706 795 0 0 26 0 26 0 0 0 0 0 502133
abtc2 26954 261791 7513 7602 0 0 42 9 32 4 0 0 0 0 4377106
bmbt2 1139 7786 139 90 0 0 0 0 0 0 0 0 0 0 1307
ibt2 28009 311571 63 42 0 0 0 0 1 0 0 0 0 0 4354
fibt2 41067 163441 8178 8255 0 0 0 0 0 0 0 0 0 0 34399
rmapbt 27442 493733 6653 4919 0 0 1540 1437 1007 1063 22 5 22 5 1032463
refcntbt 17690 177736 1608 1608 0 0 82 13 13 66 1 1 1 1 468361
rmapbt_mem 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
rcbagbt 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
rtrmapbt 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
rtrmapbt_mem 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
rtrefcntbt 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
qm 0 0 0 0 0 0 0 0
zoned 0 0 0
metafile 0
xpc 5113102336 7894530294 22776079333
defer_relog 1
debug 0
gc xpc 0

@DragonWork

Copy link
Copy Markdown
Contributor

@dongjiang1989 I sent you a PR on your fork to address this.

@dongjiang1989
dongjiang1989 force-pushed the updata-xfs-for-7.0 branch 2 times, most recently from 384f72f to 821e295 Compare May 25, 2026 02:53
@dongjiang1989

Copy link
Copy Markdown
Member Author

@dongjiang1989 I sent you a PR on your fork to address this.

Thanks @DragonWork Merged

@dongjiang1989

Copy link
Copy Markdown
Member Author

cc @SuperQ , PTAL, when U have time. thanks.

dongjiang1989 and others added 2 commits June 18, 2026 20:15
Signed-off-by: dongjiang <dongjiang1989@126.com>
fix: correct parsing of xfs stats
Signed-off-by: dongjiang <dongjiang1989@126.com>

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@SuperQ
SuperQ merged commit 653e173 into prometheus:master Jun 21, 2026
7 checks passed
blewis12 added a commit to grafana/alloy that referenced this pull request Jul 3, 2026
Bumps github.com/prometheus/procfs to v0.21.0 to incorporate [this
upstream fix](prometheus/procfs#810) - this
fixes the xfs collector in `prometheus.exporter.unix` failing on newer
kernels with `strconv.ParseUint: parsing "xpc": invalid syntax`

Addresses #6601
@dongjiang1989
dongjiang1989 deleted the updata-xfs-for-7.0 branch July 21, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants