Fix ZFS bugs (diskspace.plugin) - #22188
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Startup as Startup (diskspace_main)
participant Main as Main Thread (Fast Path)
participant Worker as Slow Worker (Thread)
participant OS as Kernel (statvfs)
participant Cache as ZFS Cache (Dictionary)
Note over Startup,Cache: Initialization Phase
Startup->>OS: NEW: is_lxcfs_proc_mounted()
OS-->>Startup: LXC status (set once)
Note over Startup,Cache: Runtime Collection Loop
rect rgb(240, 240, 240)
Note right of Main: Fast Path: Processes responsive mounts
Main->>Main: basic_mountinfo_create_and_copy()
Note right of Main: NEW: NULL guard on mi->filesystem copy
Main->>OS: statvfs(mount_point)
OS-->>Main: buff_statvfs
Main->>Cache: NEW: zfs_cache_pool_capacity(buff_statvfs)
opt If mount is ZFS Pool (no '/' in source)
Cache->>Cache: Update capacity & timestamp
end
Main->>Cache: should_exclude_zfs()
Cache-->>Main: Decision (based on heuristic)
end
rect rgb(230, 240, 250)
Note right of Worker: Slow Path: Processes network/hung mounts
Worker->>OS: statvfs(mount_point)
alt statvfs success
OS-->>Worker: buff_statvfs
Worker->>Cache: NEW: zfs_cache_pool_capacity(buff_statvfs)
Note right of Worker: Updates cache from worker thread
Worker->>Cache: should_exclude_zfs()
Cache-->>Worker: Decision
else statvfs timeout/error
OS-->>Worker: error
end
end
Note over Main,Cache: CHANGED: No separate blocking ZFS pass in Main Loop.
Note over Main,Cache: Capacity data now flows from existing statvfs calls.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses ZFS-related crashes in diskspace.plugin by hardening mountinfo copying against NULL fields and removing the extra ZFS pool-capacity statvfs pass that could block collection and contribute to instability.
Changes:
- Guard
mi->filesystemwhen copying intobasic_mountinfoto avoid NULL dereferences. - Replace
zfs_collect_pool_capacities()withzfs_cache_pool_capacity(), updating the ZFS pool-capacity cache only after already-successfulstatvfs()calls in the fast/slow paths. - Initialize LXC detection once during
diskspace_main()startup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
stelfrag
approved these changes
Apr 11, 2026
stelfrag
pushed a commit
to stelfrag/netdata
that referenced
this pull request
Apr 14, 2026
(cherry picked from commit d4e069f)
Merged
Ferroin
pushed a commit
that referenced
this pull request
Apr 14, 2026
(cherry picked from commit d4e069f)
1 task
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the following bug:
Details about the fixes:
Fixes
Bug 1 — NULL deref in basic_mountinfo_create_and_copy (line 165)// Before
bmi->filesystem = strdupz(mi->filesystem);
// After
bmi->filesystem = mi->filesystem ? strdupz(mi->filesystem) : NULL;
mount_source already had this guard; filesystem was missing it.
Bug 2 (root cause of the crash) — zfs_collect_pool_capacities removed
entirely
The function was calling statvfs() on ZFS pool mounts:
starving the slow worker thread
corruption, making mi->filesystem an invalid pointer by the next iteration
→ strcmp crash
Replaced with zfs_cache_pool_capacity() — a lightweight helper that
piggy-backs on the statvfs() call that do_disk_space_stats and
do_slow_disk_space_stats already make. No extra syscall, no extra mutex
hold time.
Test Plan
dd;Additional Information
For users: How does this change affect me?
Summary by cubic
Fixes ZFS-related coredumps in diskspace.plugin by guarding NULL filesystem fields and replacing the blocking pool-capacity collector with a cache fed by existing statvfs calls. This prevents strcmp crashes and avoids blocking the collection loop on degraded or exporting ZFS pools.
Written for commit 91ce11f. Summary will update on new commits.