Skip to content

Commit 2bdb46e

Browse files
shroffniigaw
authored andcommitted
libnvme: add support for nshead diagnostic counters
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@linux.ibm.com> Link: https://patch.msgid.link/20260421145038.3458987-9-nilay@linux.ibm.com Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent 14b9b0b commit 2bdb46e

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

libnvme/src/libnvme.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ LIBNVME_3 {
142142
libnvme_ns_get_io_ticks;
143143
libnvme_ns_get_command_retry_count;
144144
libnvme_ns_get_command_error_count;
145+
libnvme_ns_get_requeue_no_usable_path_count;
146+
libnvme_ns_get_fail_no_available_path_count;
145147
libnvme_ns_identify;
146148
libnvme_ns_read;
147149
libnvme_ns_verify;

libnvme/src/nvme/private.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ struct libnvme_ns { // !generate-accessors
255255
unsigned char uuid[NVME_UUID_LEN];
256256
enum nvme_csi csi;
257257

258-
long command_retry_count; // !accessors:none
259-
long command_error_count; // !accessors:none
258+
long command_retry_count; // !accessors:none
259+
long command_error_count; // !accessors:none
260+
long requeue_no_usable_path_count; // !accessors:none
261+
long fail_no_available_path_count; // !accessors:none
260262
};
261263

262264
struct libnvme_ctrl { // !generate-accessors

libnvme/src/nvme/tree.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,28 @@ __public long libnvme_ns_get_command_error_count(libnvme_ns_t n)
26332633
return n->command_error_count;
26342634
}
26352635

2636+
__public long libnvme_ns_get_requeue_no_usable_path_count(libnvme_ns_t n)
2637+
{
2638+
__cleanup_free char *requeue_count = NULL;
2639+
2640+
requeue_count = libnvme_get_ns_attr(n, "requeue_no_usable_path_count");
2641+
if (requeue_count)
2642+
sscanf(requeue_count, "%ld", &n->requeue_no_usable_path_count);
2643+
2644+
return n->requeue_no_usable_path_count;
2645+
}
2646+
2647+
__public long libnvme_ns_get_fail_no_available_path_count(libnvme_ns_t n)
2648+
{
2649+
__cleanup_free char *fail_count = NULL;
2650+
2651+
fail_count = libnvme_get_ns_attr(n, "fail_no_available_path_count");
2652+
if (fail_count)
2653+
sscanf(fail_count, "%ld", &n->fail_no_available_path_count);
2654+
2655+
return n->fail_no_available_path_count;
2656+
}
2657+
26362658
__public int libnvme_ns_identify(libnvme_ns_t n, struct nvme_id_ns *ns)
26372659
{
26382660
struct libnvme_transport_handle *hdl;

libnvme/src/nvme/tree.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,23 @@ long libnvme_ns_get_command_retry_count(libnvme_ns_t n);
527527
*/
528528
long libnvme_ns_get_command_error_count(libnvme_ns_t n);
529529

530+
/**
531+
* libnvme_ns_get_requeue_no_usable_path_count() - Get num of I/O requeue count
532+
* @n: &libnvme_ns_t object
533+
*
534+
* Return: Number of I/Os which are re-queued due to the unavalibility of
535+
* any usable path (maybe path is currently experiencing transinet link failure)
536+
*/
537+
long libnvme_ns_get_requeue_no_usable_path_count(libnvme_ns_t n);
538+
539+
/**
540+
* libnvme_ns_get_fail_no_available_path_count() - Get num of I/Os forced to fail
541+
* @n: &libnvme_ns_t object
542+
*
543+
* Return: Number of I/Os which are forced to fail due to no path available
544+
*/
545+
long libnvme_ns_get_fail_no_available_path_count(libnvme_ns_t n);
546+
530547
/**
531548
* libnvme_ns_get_generic_name() - Returns name of generic namespace chardev.
532549
* @n: Namespace instance

0 commit comments

Comments
 (0)