Repository navigation
sysfs: parse NVMe diag counters (controller, namespace, multipath head) - #887
Conversation
There was a problem hiding this comment.
I'm wondering if we should split this out into a separate function from NVMeClass().
Adding a whole new dataset is going to increase the amount of load caused by all the file reading/parsing when it's less used.
Maybe we could implement this as a functions on NVMeDevice
Something like this:
func (d *NVMeDevice) NamespaceDiag() NVMeNamespaceDiag {
}
Linux 7.2 added a diag/ attribute group to NVMe controllers and namespace block devices: /sys/class/nvme/<ctrl>/diag/command_error_count /sys/class/nvme/<ctrl>/diag/reset_count /sys/class/nvme/<ctrl>/diag/reconnect_count (fabrics only) /sys/class/nvme/<ctrl>/<ns>/diag/command_retries_count /sys/class/nvme/<ctrl>/<ns>/diag/command_error_count /sys/class/nvme/<ctrl>/<ns>/diag/multipath_failover_count Add NVMeDevice.Diag and NVMeDevice.NamespaceDiag to read them on demand, so NVMeClass does not read the extra files for callers that do not need them. NVMeDevice gains a Path field with its sysfs directory for the methods to read from. Every counter is a pointer and stays nil when the running kernel does not provide the attribute, so older kernels and PCIe controllers (which have no reconnect_count) keep working. Signed-off-by: Lakshmi Pradeep <lakshmi.pradeep@neyon.ai>
Linux 7.2 exposes two counters on each native-multipath namespace head: /sys/class/nvme-subsystem/<subsys>/<ns>/diag/io_requeue_no_usable_path_count /sys/class/nvme-subsystem/<subsys>/<ns>/diag/io_fail_no_available_path_count They show I/O that was queued or failed because every path to the namespace was down, which per-path counters cannot show. Add NVMeSubsystem.NamespaceDiag to read them on demand for one of the subsystem's namespaces, so NVMeSubsystemClass does not read the extra files. NVMeSubsystem gains a Path field with its sysfs directory for the method to read from. Counters the kernel does not provide stay nil. Signed-off-by: Lakshmi Pradeep <lakshmi.pradeep@neyon.ai>
e320836 to
e3b2072
Compare
|
Thanks for the suggestion. I've reworked it along those lines: func (d NVMeDevice) Diag() (NVMeControllerDiag, error)
func (d NVMeDevice) NamespaceDiag(namespace string) (NVMeNamespaceDiag, error)
func (s NVMeSubsystem) NamespaceDiag(namespace string) (NVMeSubsystemNamespaceDiag, error)
|
Follow-up to #885, as mentioned there.
Linux 7.2 added
diag/attribute groups with error and recovery counters for NVMe controllers, namespace block devices and native-multipath namespace heads. This adds methods to read them on demand:NVMeDevice.Diag()/sys/class/nvme/<ctrl>/diag/{command_error_count,reset_count,reconnect_count}(reconnect_countis fabrics-only)NVMeDevice.NamespaceDiag(ns)/sys/class/nvme/<ctrl>/<ns>/diag/{command_retries_count,command_error_count,multipath_failover_count}NVMeSubsystem.NamespaceDiag(ns)/sys/class/nvme-subsystem/<subsys>/<ns>/diag/{io_requeue_no_usable_path_count,io_fail_no_available_path_count}The head counters show I/O that was requeued or failed because every path was down, which the per-path counters cannot show.
NVMeClass()andNVMeSubsystemClass()read exactly the same files as before; the diag files are only read when a method is called.NVMeDeviceandNVMeSubsystemgain aPathfield with their sysfs directory for the methods to read from. Every counter is a pointer and stays nil when the kernel does not provide the attribute, so older kernels and PCIe controllers (noreconnect_count) work unchanged. Namespace names that do not match the NVMe naming pattern are rejected.Tests: fixtures extended with
diag/attributes for controllers, namespaces and a multipath head; new tests cover each method, a kernel withoutdiag/, and invalid names. Test pointers usenew(uint64(...))following #865.The node_exporter
nvmeandnvmesubsystemcollector changes that expose these are ready and will follow once this is merged.