From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me, axboe@fb.com,
gjoyce@linux.ibm.com, Nilay Shroff <nilay@linux.ibm.com>
Subject: [PATCH RFC 1/1] nvme-multipath: Add debugfs entry for showing multipath info
Date: Mon, 22 Jul 2024 15:01:10 +0530 [thread overview]
Message-ID: <20240722093124.42581-3-nilay@linux.ibm.com> (raw)
In-Reply-To: <20240722093124.42581-1-nilay@linux.ibm.com>
NVMe native multipath supports different io policies for selecting
I/O path, however, we don't have any visibility about which path is
being selected by multipath code for forwarding I/O. This patch helps
add that visibility by adding a debugfs file for each head disk node
on the system. It creates a file named "multipath" under
"/sys/kernel/debug/block/nvmeXnY/". This file shows the information
about current selected "io-policy" as well as it prints a "table"
showing information about each online node and it's respective I/O
path, controller name, ana-state and optionally queue depth of each
path (if selected io-policy is queue-depth).
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
drivers/nvme/host/multipath.c | 90 +++++++++++++++++++++++++++++++++++
drivers/nvme/host/nvme.h | 1 +
2 files changed, 91 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 91d9eb3c22ef..143d4b279b43 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -6,6 +6,7 @@
#include <linux/backing-dev.h>
#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
+#include <linux/debugfs.h>
#include <trace/events/block.h>
#include "nvme.h"
@@ -628,6 +629,91 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
ctrl->subsys->instance, head->instance);
return 0;
}
+static void nvme_mpath_numa_show(struct seq_file *m, struct nvme_ns_head *head)
+{
+ int node;
+ struct nvme_ns *ns;
+
+ seq_printf(m, "%-4s %-12s %-6s %s\n",
+ "node", "current-path", "ctrl", "ana-state");
+
+ for_each_online_node(node) {
+ ns = srcu_dereference(head->current_path[node], &head->srcu);
+ if (ns)
+ seq_printf(m, "%-4d %-12s %-6s %s\n",
+ node, ns->disk->disk_name,
+ dev_name(ns->ctrl->device),
+ nvme_ana_state_names[ns->ana_state]);
+ }
+}
+
+static void nvme_mpath_rr_show(struct seq_file *m, struct nvme_ns_head *head)
+{
+ int node;
+ struct nvme_ns *ns;
+
+ seq_printf(m, "%-4s %-12s %-6s %s\n",
+ "node", "rr-path", "ctrl", "ana-state");
+
+ for_each_online_node(node) {
+ list_for_each_entry_rcu(ns, &head->list, siblings) {
+ seq_printf(m, "%-4d %-12s %-6s %s\n",
+ node, ns->disk->disk_name,
+ dev_name(ns->ctrl->device),
+ nvme_ana_state_names[ns->ana_state]);
+ }
+ }
+}
+
+static void nvme_mpath_qd_show(struct seq_file *m, struct nvme_ns_head *head)
+{
+ int node;
+ struct nvme_ns *ns;
+
+ seq_printf(m, "%-4s %-12s %-6s %-10s %s\n",
+ "node", "path", "ctrl", "qdepth", "ana-state");
+
+ for_each_online_node(node) {
+ list_for_each_entry_rcu(ns, &head->list, siblings) {
+ seq_printf(m, "%-4d %-12s %-6s %-10d %s\n",
+ node, ns->disk->disk_name,
+ dev_name(ns->ctrl->device),
+ atomic_read(&ns->ctrl->nr_active),
+ nvme_ana_state_names[ns->ana_state]);
+
+ }
+ }
+}
+
+static int nvme_mpath_show(struct seq_file *m, void *p)
+{
+ struct nvme_ns_head *head = m->private;
+ int iopolicy = READ_ONCE(head->subsys->iopolicy);
+
+ seq_printf(m, "io-policy: %s\n", nvme_iopolicy_names[iopolicy]);
+
+ seq_puts(m, "io-path:\n");
+ seq_puts(m, "--------\n");
+
+ if (iopolicy == NVME_IOPOLICY_NUMA)
+ nvme_mpath_numa_show(m, head);
+ else if (iopolicy == NVME_IOPOLICY_RR)
+ nvme_mpath_rr_show(m, head);
+ else if (iopolicy == NVME_IOPOLICY_QD)
+ nvme_mpath_qd_show(m, head);
+
+ return 0;
+}
+
+static int nvme_mpath_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, nvme_mpath_show, inode->i_private);
+}
+static const struct file_operations nvme_mpath_fops = {
+ .open = nvme_mpath_open,
+ .read = seq_read,
+ .release = single_release
+};
static void nvme_mpath_set_live(struct nvme_ns *ns)
{
@@ -650,6 +736,9 @@ static void nvme_mpath_set_live(struct nvme_ns *ns)
return;
}
nvme_add_ns_head_cdev(head);
+ head->debugfs = debugfs_create_file("multipath", 0400,
+ head->disk->queue->debugfs_dir, head,
+ &nvme_mpath_fops);
}
mutex_lock(&head->lock);
@@ -969,6 +1058,7 @@ void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)
return;
kblockd_schedule_work(&head->requeue_work);
if (test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) {
+ debugfs_remove(head->debugfs);
nvme_cdev_del(&head->cdev, &head->cdev_device);
del_gendisk(head->disk);
}
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index f900e44243ae..5b4c0b70cedf 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -493,6 +493,7 @@ struct nvme_ns_head {
struct work_struct requeue_work;
struct mutex lock;
unsigned long flags;
+ struct dentry *debugfs;
#define NVME_NSHEAD_DISK_LIVE 0
struct nvme_ns __rcu *current_path[];
#endif
--
2.45.2
next prev parent reply other threads:[~2024-07-22 9:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 9:31 [PATCH RFC 0/1] Add visibility for native NVMe miltipath using debugfs Nilay Shroff
2024-07-22 9:31 ` Nilay Shroff [this message]
2024-07-22 14:18 ` Daniel Wagner
2024-07-23 5:18 ` Nilay Shroff
2024-07-23 7:40 ` Daniel Wagner
2024-07-24 13:41 ` Christoph Hellwig
2024-07-25 6:23 ` Nilay Shroff
2024-07-24 14:37 ` Keith Busch
2024-07-25 6:20 ` Nilay Shroff
2024-07-28 20:47 ` Sagi Grimberg
2024-07-29 4:50 ` Nilay Shroff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240722093124.42581-3-nilay@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@fb.com \
--cc=gjoyce@linux.ibm.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.