Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvme-multipath: add iopolicies sysfs attribute
@ 2026-09-21 14:43 loberman
  2026-09-22 13:38 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: loberman @ 2026-09-21 14:43 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, kbusch, sagi, Laurence Oberman

From: Laurence Oberman <loberman@redhat.com>

The subsystem iopolicy attribute only shows the active policy, so
there is no way to see which policies are available.

Changing the output of iopolicy would break existing userspace,
since nvme-cli compares the value against a bare policy name. Leave
iopolicy unchanged and add a read-only iopolicies attribute that
lists the available policies:

  # cat iopolicies
  numa round-robin queue-depth

The current policy is still read from iopolicy.

Signed-off-by: Laurence Oberman <loberman@redhat.com>
Assisted-by: Claude:claude-sonnet-5
---
v2:
  - Drop the [ ] notation and list plain policy names (Christoph)

 drivers/nvme/host/multipath.c | 15 +++++++++++++++
 drivers/nvme/host/nvme.h      |  1 +
 drivers/nvme/host/sysfs.c     |  1 +
 3 files changed, 17 insertions(+)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 75dbb58286a3..ea7d0c59587b 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1085,6 +1085,21 @@ static ssize_t nvme_subsys_iopolicy_store(struct device *dev,
 SUBSYS_ATTR_RW(iopolicy, S_IRUGO | S_IWUSR,
 		      nvme_subsys_iopolicy_show, nvme_subsys_iopolicy_store);
 
+static ssize_t iopolicies_show(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	int i, len = 0;
+
+	for (i = 0; i < ARRAY_SIZE(nvme_iopolicy_names); i++)
+		len += sysfs_emit_at(buf, len, "%s%s", i ? " " : "",
+				     nvme_iopolicy_names[i]);
+
+	len += sysfs_emit_at(buf, len, "\n");
+	return len;
+}
+
+struct device_attribute subsys_attr_iopolicies = __ATTR_RO(iopolicies);
+
 static ssize_t ana_grpid_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 75e5d5a8a77c..b419c6fc6081 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1098,6 +1098,7 @@ extern struct device_attribute dev_attr_multipath_failover_count;
 extern struct device_attribute dev_attr_io_requeue_no_usable_path_count;
 extern struct device_attribute dev_attr_io_fail_no_available_path_count;
 extern struct device_attribute subsys_attr_iopolicy;
+extern struct device_attribute subsys_attr_iopolicies;
 
 static inline bool nvme_disk_is_ns_head(struct gendisk *disk)
 {
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index abf8edaae371..4c4518b6b7d5 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -1298,6 +1298,7 @@ static struct attribute *nvme_subsys_attrs[] = {
 	&subsys_attr_subsystype.attr,
 #ifdef CONFIG_NVME_MULTIPATH
 	&subsys_attr_iopolicy.attr,
+	&subsys_attr_iopolicies.attr,
 #endif
 	NULL,
 };
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvme-multipath: add iopolicies sysfs attribute
  2026-09-21 14:43 [PATCH v2] nvme-multipath: add iopolicies sysfs attribute loberman
@ 2026-09-22 13:38 ` Christoph Hellwig
  2026-09-22 14:24 ` John Garry
  2026-09-22 15:04 ` Keith Busch
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-09-22 13:38 UTC (permalink / raw)
  To: loberman; +Cc: linux-nvme, kbusch, sagi

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvme-multipath: add iopolicies sysfs attribute
  2026-09-21 14:43 [PATCH v2] nvme-multipath: add iopolicies sysfs attribute loberman
  2026-09-22 13:38 ` Christoph Hellwig
@ 2026-09-22 14:24 ` John Garry
  2026-09-22 15:04 ` Keith Busch
  2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2026-09-22 14:24 UTC (permalink / raw)
  To: loberman, linux-nvme; +Cc: hch, kbusch, sagi

On 9/21/26 15:43, loberman@redhat.com wrote:
> From: Laurence Oberman <loberman@redhat.com>
> 
> The subsystem iopolicy attribute only shows the active policy, so
> there is no way to see which policies are available.
> 
> Changing the output of iopolicy would break existing userspace,
> since nvme-cli compares the value against a bare policy name. Leave
> iopolicy unchanged and add a read-only iopolicies attribute that
> lists the available policies:
> 
>    # cat iopolicies
>    numa round-robin queue-depth
> 
> The current policy is still read from iopolicy.
> 
> Signed-off-by: Laurence Oberman <loberman@redhat.com>

Apart from comment below:

Reviewed-by: John Garry <john.garry@linux.dev>

> Assisted-by: Claude:claude-sonnet-5
> ---
> v2:
>    - Drop the [ ] notation and list plain policy names (Christoph)
> 
>   drivers/nvme/host/multipath.c | 15 +++++++++++++++
>   drivers/nvme/host/nvme.h      |  1 +
>   drivers/nvme/host/sysfs.c     |  1 +
>   3 files changed, 17 insertions(+)
> 
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 75dbb58286a3..ea7d0c59587b 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -1085,6 +1085,21 @@ static ssize_t nvme_subsys_iopolicy_store(struct device *dev,
>   SUBSYS_ATTR_RW(iopolicy, S_IRUGO | S_IWUSR,
>   		      nvme_subsys_iopolicy_show, nvme_subsys_iopolicy_store);
>   
> +static ssize_t iopolicies_show(struct device *dev,
> +			       struct device_attribute *attr, char *buf)
> +{
> +	int i, len = 0;
> +
> +	for (i = 0; i < ARRAY_SIZE(nvme_iopolicy_names); i++)
 > +		len += sysfs_emit_at(buf, len, "%s%s", i ? " " : "",> +				 
nvme_iopolicy_names[i]);
> +
> +	len += sysfs_emit_at(buf, len, "\n");
> +	return len;
> +}
> +
> +struct device_attribute subsys_attr_iopolicies = __ATTR_RO(iopolicies);

SUBSYS_ATTR_RO already exists for this, right?

> +
>   static ssize_t ana_grpid_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 75e5d5a8a77c..b419c6fc6081 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -1098,6 +1098,7 @@ extern struct device_attribute dev_attr_multipath_failover_count;
>   extern struct device_attribute dev_attr_io_requeue_no_usable_path_count;
>   extern struct device_attribute dev_attr_io_fail_no_available_path_count;
>   extern struct device_attribute subsys_attr_iopolicy;
> +extern struct device_attribute subsys_attr_iopolicies;
>   
>   static inline bool nvme_disk_is_ns_head(struct gendisk *disk)
>   {
> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index abf8edaae371..4c4518b6b7d5 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
> @@ -1298,6 +1298,7 @@ static struct attribute *nvme_subsys_attrs[] = {
>   	&subsys_attr_subsystype.attr,
>   #ifdef CONFIG_NVME_MULTIPATH
>   	&subsys_attr_iopolicy.attr,
> +	&subsys_attr_iopolicies.attr,
>   #endif
>   	NULL,
>   };



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] nvme-multipath: add iopolicies sysfs attribute
  2026-09-21 14:43 [PATCH v2] nvme-multipath: add iopolicies sysfs attribute loberman
  2026-09-22 13:38 ` Christoph Hellwig
  2026-09-22 14:24 ` John Garry
@ 2026-09-22 15:04 ` Keith Busch
  2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2026-09-22 15:04 UTC (permalink / raw)
  To: loberman; +Cc: linux-nvme, hch, sagi

On Mon, Sep 21, 2026 at 10:43:47AM -0400, loberman@redhat.com wrote:
> From: Laurence Oberman <loberman@redhat.com>
> 
> The subsystem iopolicy attribute only shows the active policy, so
> there is no way to see which policies are available.
> 
> Changing the output of iopolicy would break existing userspace,
> since nvme-cli compares the value against a bare policy name. Leave
> iopolicy unchanged and add a read-only iopolicies attribute that
> lists the available policies:
> 
>   # cat iopolicies
>   numa round-robin queue-depth
> 
> The current policy is still read from iopolicy.

Thanks, applied to nvme-7.4.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-22 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21 14:43 [PATCH v2] nvme-multipath: add iopolicies sysfs attribute loberman
2026-09-22 13:38 ` Christoph Hellwig
2026-09-22 14:24 ` John Garry
2026-09-22 15:04 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox