Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Martin George <martinus.gpy@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me,
	loberman@redhat.com, Martin George <marting@netapp.com>
Subject: [PATCH] nvme-multipath: report "none" iopolicy for discovery subsystems
Date: Wed, 30 Sep 2026 21:06:58 +0530	[thread overview]
Message-ID: <20260930153658.4002-1-marting@netapp.com> (raw)

A discovery subsystem never exposes namespaces, so it has no multipath
head and no I/O paths to select between. Nevertheless the per-subsystem
iopolicy attribute is registered unconditionally and reads back the
driver-wide default which is 'numa' for the discovery subsystems too.
This can be misleading as it suggests a path selection policy is in
effect when nothing is ever selected, and writing the attribute silently
mutates state that can never be used.

Report "none" instead for a discovery subsystem, and reject writes
with -EOPNOTSUPP. Report "none" from iopolicies as well, so that the
value read from iopolicy always remains a member of the set advertised
by iopolicies; otherwise userspace validating the current policy
against the available ones would reject its own subsystem.

And while at it, document iopolicies too, which was not covered when it
was added previously.

Signed-off-by: Martin George <marting@netapp.com>
---
 Documentation/ABI/stable/sysfs-nvme | 15 +++++++++++++++
 drivers/nvme/host/multipath.c       | 12 ++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/Documentation/ABI/stable/sysfs-nvme b/Documentation/ABI/stable/sysfs-nvme
index a0bb88ca1694..67795a2dd905 100644
--- a/Documentation/ABI/stable/sysfs-nvme
+++ b/Documentation/ABI/stable/sysfs-nvme
@@ -465,6 +465,21 @@ Description:
 		selections. Only available when CONFIG_NVME_MULTIPATH is
 		enabled.
 
+		A discovery subsystem has no namespaces and hence no I/O
+		paths to select from: reading returns "none" and writing
+		fails with EOPNOTSUPP.
+
+What:		/sys/class/nvme-subsystem/nvme-subsysX/iopolicies
+Date:		September 2026
+KernelVersion:	7.4
+Contact:	Laurence Oberman <loberman@redhat.com>
+Description:
+		Shows the I/O path selection policies that may be written
+		to the iopolicy attribute of this subsystem, separated by
+		spaces: "numa round-robin queue-depth". A discovery
+		subsystem accepts no policy at all and reports "none".
+		Only available when CONFIG_NVME_MULTIPATH is enabled.
+
 What:		/sys/class/nvme-subsystem/nvme-subsysX/subsystype
 Date:		September 2021
 KernelVersion:	5.16
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 11871f5f18c2..56ee25b448ad 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1054,6 +1054,10 @@ static ssize_t nvme_subsys_iopolicy_show(struct device *dev,
 	struct nvme_subsystem *subsys =
 		container_of(dev, struct nvme_subsystem, dev);
 
+	/* A discovery subsystem has no namespaces and hence no I/O paths */
+	if (subsys->subtype == NVME_NQN_DISC)
+		return sysfs_emit(buf, "none\n");
+
 	return sysfs_emit(buf, "%s\n",
 			  nvme_iopolicy_names[READ_ONCE(subsys->iopolicy)]);
 }
@@ -1088,6 +1092,9 @@ static ssize_t nvme_subsys_iopolicy_store(struct device *dev,
 		container_of(dev, struct nvme_subsystem, dev);
 	int policy;
 
+	if (subsys->subtype == NVME_NQN_DISC)
+		return -EOPNOTSUPP;
+
 	policy = nvme_iopolicy_parse(buf);
 	if (policy < 0)
 		return policy;
@@ -1101,8 +1108,13 @@ SUBSYS_ATTR_RW(iopolicy, S_IRUGO | S_IWUSR,
 static ssize_t iopolicies_show(struct device *dev,
 			       struct device_attribute *attr, char *buf)
 {
+	struct nvme_subsystem *subsys =
+		container_of(dev, struct nvme_subsystem, dev);
 	int i, len = 0;
 
+	if (subsys->subtype == NVME_NQN_DISC)
+		return sysfs_emit(buf, "none\n");
+
 	for (i = 0; i < ARRAY_SIZE(nvme_iopolicy_names); i++)
 		len += sysfs_emit_at(buf, len, "%s%s", i ? " " : "",
 				     nvme_iopolicy_names[i]);
-- 
2.43.0



             reply	other threads:[~2026-09-30 15:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 15:36 Martin George [this message]
2026-09-30 16:00 ` [PATCH] nvme-multipath: report "none" iopolicy for discovery subsystems Laurence Oberman

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=20260930153658.4002-1-marting@netapp.com \
    --to=martinus.gpy@gmail.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=loberman@redhat.com \
    --cc=marting@netapp.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox