Skip to content

Commit ed3d575

Browse files
committed
DLPX-88427 Fix garbage stat names in estat metaslab-alloc BPF program
PR URL: https://www.github.com/delphix/performance-diagnostics/pull/121
1 parent 9408dc6 commit ed3d575

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

bpf/estat/metaslab-alloc.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
* SPDX-License-Identifier: GPL-2.0-or-later
55
*/
66

7+
/*
8+
* On some kernel versions (e.g. 6.14) linux/bpf.h is pulled in transitively
9+
* via metaslab.h -> spa.h -> zfs_context.h -> vfs.h -> security.h and
10+
* contains sizeof(struct bpf_wq) where bpf_wq is only forward-declared,
11+
* causing a compile error (DLPX-96701). Blocking security.h (which this BPF
12+
* program does not need) stops the chain without touching linux/bpf.h itself.
13+
*/
14+
#define __LINUX_SECURITY_H
15+
716
#include <sys/metaslab.h>
817
#include <sys/metaslab_impl.h>
918
#include <sys/vdev_impl.h>
@@ -103,6 +112,19 @@ metaslab_group_alloc_exit(struct pt_regs *ctx)
103112
axis = success;
104113
}
105114

115+
/*
116+
* On some engine versions a kernel bug (DLPX-88427) causes vd_name to
117+
* contain raw memory bytes instead of a vdev path or type string. The
118+
* first byte of any valid name is either '/' (device path) or an ASCII
119+
* letter (vdev type like "mirror"). If it falls outside printable ASCII
120+
* (0x20–0x7e) the name is garbage; overwrite it with a safe fallback so
121+
* we never emit unparseable metric names.
122+
*/
123+
if (data->vd_name[0] < 0x20 || data->vd_name[0] > 0x7e) {
124+
char unknown[] = "unknown";
125+
__builtin_memcpy(data->vd_name, unknown, sizeof(unknown));
126+
}
127+
106128
AGGREGATE_DATA(data->vd_name, axis,
107129
bpf_ktime_get_ns() - data->ts, data->asize);
108130

telegraf/metaslab-alloc-stats.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

telegraf/telegraf.inputs.playbook

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,9 @@
9191
]
9292
json_string_fields = ["iops(/s)", "avg latency(us)", "stddev(us)", "throughput(k/s)", "microseconds"]
9393

94-
# Collect output from "estat metaslab-alloc -jm 10" via wrapper script.
95-
# The wrapper filters out metrics with garbage "name" tags (DLPX-88427).
94+
# Collect output from "estat metaslab-alloc -jm 10"
9695
[[inputs.execd]]
97-
command = ["/etc/telegraf/metaslab-alloc-stats.sh"]
96+
command = ["estat", "metaslab-alloc", "-jm", "10"]
9897
name_override = "estat_metaslab-alloc"
9998
signal = "none"
10099
restart_delay = "30s"

0 commit comments

Comments
 (0)