From: hare@kernel.org
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 3/6] nvme: add per-namespace iopolicy sysfs attribute
Date: Tue, 29 Jul 2025 09:06:50 +0200 [thread overview]
Message-ID: <20250729070653.125258-4-hare@kernel.org> (raw)
In-Reply-To: <20250729070653.125258-1-hare@kernel.org>
From: Hannes Reinecke <hare@kernel.org>
To display iopolicies which are different from the subsystem.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
drivers/nvme/host/multipath.c | 14 ++++++++++++++
drivers/nvme/host/nvme.h | 1 +
drivers/nvme/host/sysfs.c | 7 +++++++
3 files changed, 22 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 116b2e71d339..696c2f817bed 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1137,6 +1137,20 @@ static ssize_t numa_nodes_show(struct device *dev, struct device_attribute *attr
}
DEVICE_ATTR_RO(numa_nodes);
+static ssize_t iopolicy_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gendisk *disk = dev_to_disk(dev);
+ struct nvme_ns_head *head = disk->private_data;
+ int iopolicy;
+
+ if (nvme_bpf_enabled(head))
+ return sysfs_emit(buf, "bpf(%pUb)\n", &head->bpf_ops->uuid);
+ iopolicy = READ_ONCE(head->subsys->iopolicy);
+ return sysfs_emit(buf, "%s\n", nvme_iopolicy_names[iopolicy]);
+}
+DEVICE_ATTR_RO(iopolicy);
+
static ssize_t delayed_removal_secs_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index f1eb8ae57c84..2aff8df55d1c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -994,6 +994,7 @@ extern struct device_attribute dev_attr_ana_grpid;
extern struct device_attribute dev_attr_ana_state;
extern struct device_attribute dev_attr_queue_depth;
extern struct device_attribute dev_attr_numa_nodes;
+extern struct device_attribute dev_attr_iopolicy;
extern struct device_attribute dev_attr_delayed_removal_secs;
extern struct device_attribute subsys_attr_iopolicy;
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 29430949ce2f..378107cf7a21 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -260,6 +260,7 @@ static struct attribute *nvme_ns_attrs[] = {
&dev_attr_ana_state.attr,
&dev_attr_queue_depth.attr,
&dev_attr_numa_nodes.attr,
+ &dev_attr_iopolicy.attr,
&dev_attr_delayed_removal_secs.attr,
#endif
&dev_attr_io_passthru_err_log_enabled.attr,
@@ -297,6 +298,12 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
if (nvme_disk_is_ns_head(dev_to_disk(dev)))
return 0;
}
+ if (a == &dev_attr_iopolicy.attr) {
+ struct gendisk *disk = dev_to_disk(dev);
+
+ if (!nvme_disk_is_ns_head(disk))
+ return 0;
+ }
if (a == &dev_attr_delayed_removal_secs.attr) {
struct gendisk *disk = dev_to_disk(dev);
--
2.43.0
next prev parent reply other threads:[~2025-07-29 7:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 7:06 [RFC PATCH 0/6] nvme multipath eBPF path selector hare
2025-07-29 7:06 ` [PATCH 1/6] nvme-multipath: do not assign ->current_path in __nvme_find_path() hare
2025-07-29 7:06 ` [PATCH 2/6] nvme: export nvme_find_get_subsystem()/nvme_put_subsystem() hare
2025-07-29 7:06 ` hare [this message]
2025-07-29 7:06 ` [PATCH 4/6] nvme: add 'sector' parameter to nvme_find_path() hare
2025-07-29 7:06 ` [PATCH 5/6] nvme-bpf: eBPF struct_ops path selectors hare
2025-07-29 7:06 ` [PATCH 6/6] tools/testing/selftests: add sample nvme bpf path selector hare
2025-07-30 2:03 ` Geliang Tang
2025-07-30 5:56 ` Hannes Reinecke
2025-07-29 7:54 ` [RFC PATCH 0/6] nvme multipath eBPF " Christoph Hellwig
2025-07-29 14:53 ` Mike Christie
2025-07-30 14:06 ` Christoph Hellwig
2025-07-30 2:03 ` Geliang Tang
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=20250729070653.125258-4-hare@kernel.org \
--to=hare@kernel.org \
--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.