[PATCHv3 8/9] libnvme: add support for nshead diagnostic counters
Nilay Shroff
nilay at linux.ibm.com
Tue Apr 21 07:50:29 PDT 2026
Add support for retrieving nshead diagnostic counters such as requeue_
no_usable_path_count and fail_no_available_path_count.
The requeue_no_usable_path_count counter represents the number of I/Os
requeued to the namespace head when no usable path is available (for
example, due to transient link issues). The fail_no_available_path_count
counter represents the number of I/Os failed when no I/O path is
available (for example, when all paths are removed).
These counters improve visibility into NVMe native multipath behavior
and can be useful for tools such as nvme-top to display real-time
statistics.
Unlike other sysfs attributes, these counters can change dynamically.
Annotate them with "!accessors:none" and provide custom implementations
to always retrieve the latest (non-cached) values.
Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
libnvme/src/libnvme.ld | 2 ++
libnvme/src/nvme/private.h | 2 ++
libnvme/src/nvme/tree.c | 22 ++++++++++++++++++++++
libnvme/src/nvme/tree.h | 17 +++++++++++++++++
4 files changed, 43 insertions(+)
diff --git a/libnvme/src/libnvme.ld b/libnvme/src/libnvme.ld
index 2fafd333c..c9841e45c 100644
--- a/libnvme/src/libnvme.ld
+++ b/libnvme/src/libnvme.ld
@@ -142,6 +142,8 @@ LIBNVME_3 {
libnvme_ns_get_io_ticks;
libnvme_ns_get_command_retry_count;
libnvme_ns_get_command_error_count;
+ libnvme_ns_get_requeue_no_usable_path_count;
+ libnvme_ns_get_fail_no_available_path_count;
libnvme_ns_identify;
libnvme_ns_read;
libnvme_ns_verify;
diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h
index ec0e1e848..170445927 100644
--- a/libnvme/src/nvme/private.h
+++ b/libnvme/src/nvme/private.h
@@ -254,6 +254,8 @@ struct libnvme_ns { // !generate-accessors
long command_retry_count; //!accessors:none
long command_error_count; //!accessors:none
+ long requeue_no_usable_path_count; //!accessors:none
+ long fail_no_available_path_count; //!accessors:none
};
struct libnvme_ctrl { // !generate-accessors
diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c
index f1a1311b7..085d79558 100644
--- a/libnvme/src/nvme/tree.c
+++ b/libnvme/src/nvme/tree.c
@@ -2633,6 +2633,28 @@ __public long libnvme_ns_get_command_error_count(libnvme_ns_t n)
return n->command_error_count;
}
+__public long libnvme_ns_get_requeue_no_usable_path_count(libnvme_ns_t n)
+{
+ __cleanup_free char *requeue_count = NULL;
+
+ requeue_count = libnvme_get_ns_attr(n, "requeue_no_usable_path_count");
+ if (requeue_count)
+ sscanf(requeue_count, "%ld", &n->requeue_no_usable_path_count);
+
+ return n->requeue_no_usable_path_count;
+}
+
+__public long libnvme_ns_get_fail_no_available_path_count(libnvme_ns_t n)
+{
+ __cleanup_free char *fail_count = NULL;
+
+ fail_count = libnvme_get_ns_attr(n, "fail_no_available_path_count");
+ if (fail_count)
+ sscanf(fail_count, "%ld", &n->fail_no_available_path_count);
+
+ return n->fail_no_available_path_count;
+}
+
__public int libnvme_ns_identify(libnvme_ns_t n, struct nvme_id_ns *ns)
{
struct libnvme_transport_handle *hdl;
diff --git a/libnvme/src/nvme/tree.h b/libnvme/src/nvme/tree.h
index 63cd20838..6bfc8cf98 100644
--- a/libnvme/src/nvme/tree.h
+++ b/libnvme/src/nvme/tree.h
@@ -527,6 +527,23 @@ long libnvme_ns_get_command_retry_count(libnvme_ns_t n);
*/
long libnvme_ns_get_command_error_count(libnvme_ns_t n);
+/**
+ * libnvme_ns_get_requeue_no_usable_path_count() - Get num of I/O requeue count
+ * @n: &libnvme_ns_t object
+ *
+ * Return: Number of I/Os which are re-queued due to the unavalibility of
+ * any usable path (maybe path is currently experiencing transinet link failure)
+ */
+long libnvme_ns_get_requeue_no_usable_path_count(libnvme_ns_t n);
+
+/**
+ * libnvme_ns_get_fail_no_available_path_count() - Get num of I/Os forced to fail
+ * @n: &libnvme_ns_t object
+ *
+ * Return: Number of I/Os which are forced to fail due to no path available
+ */
+long libnvme_ns_get_fail_no_available_path_count(libnvme_ns_t n);
+
/**
* libnvme_ns_get_generic_name() - Returns name of generic namespace chardev.
* @n: Namespace instance
--
2.53.0
More information about the Linux-nvme
mailing list