* [PATCH] nvme: add nvme_is_disc_subsys() helper
@ 2026-10-22 7:31 Martin George
2026-10-28 14:58 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Martin George @ 2026-10-22 7:31 UTC (permalink / raw)
To: linux-nvme; +Cc: hch, kbusch, sagi, Martin George
Mirror the target's nvmet_is_disc_subsys() with a host-side
nvme_is_disc_subsys() helper, and use it for the open-coded
subtype == NVME_NQN_DISC checks in the host code to help
maintain consistency and improve code readability.
And while here, fix an error message to refer to the subsystem
rather than the controller.
Signed-off-by: Martin George <marting@netapp.com>
---
drivers/nvme/host/core.c | 4 ++--
drivers/nvme/host/multipath.c | 6 +++---
drivers/nvme/host/nvme.h | 5 +++++
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 531f9bb14bab..96b1dddf439b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3329,9 +3329,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
else
subsys->subtype = NVME_NQN_NVME;
- if (nvme_discovery_ctrl(ctrl) && subsys->subtype != NVME_NQN_DISC) {
+ if (nvme_discovery_ctrl(ctrl) && !nvme_is_disc_subsys(subsys)) {
dev_err(ctrl->device,
- "Subsystem %s is not a discovery controller",
+ "Subsystem %s is not a discovery subsystem",
subsys->subnqn);
kfree(subsys);
return -EINVAL;
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 87b934b46b85..1140491d58dd 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1072,7 +1072,7 @@ static ssize_t nvme_subsys_iopolicy_show(struct device *dev,
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)
+ if (nvme_is_disc_subsys(subsys))
return sysfs_emit(buf, "none\n");
return sysfs_emit(buf, "%s\n",
@@ -1109,7 +1109,7 @@ 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)
+ if (nvme_is_disc_subsys(subsys))
return -EOPNOTSUPP;
policy = nvme_iopolicy_parse(buf);
@@ -1129,7 +1129,7 @@ static ssize_t iopolicies_show(struct device *dev,
container_of(dev, struct nvme_subsystem, dev);
int i, len = 0;
- if (subsys->subtype == NVME_NQN_DISC)
+ if (nvme_is_disc_subsys(subsys))
return sysfs_emit(buf, "none\n");
for (i = 0; i < ARRAY_SIZE(nvme_iopolicy_names); i++)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a8ef62b8e34b..ace9119d0c09 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -522,6 +522,11 @@ struct nvme_subsystem {
#endif
};
+static inline bool nvme_is_disc_subsys(struct nvme_subsystem *subsys)
+{
+ return subsys->subtype != NVME_NQN_NVME;
+}
+
/*
* Container structure for uniqueue namespace identifiers.
*/
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: add nvme_is_disc_subsys() helper
2026-10-22 7:31 [PATCH] nvme: add nvme_is_disc_subsys() helper Martin George
@ 2026-10-28 14:58 ` Christoph Hellwig
2026-10-28 15:34 ` Martin George
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-10-28 14:58 UTC (permalink / raw)
To: Martin George; +Cc: linux-nvme, hch, kbusch, sagi, Martin George
On Thu, Oct 22, 2026 at 01:01:44PM +0530, Martin George wrote:
> Mirror the target's nvmet_is_disc_subsys() with a host-side
> nvme_is_disc_subsys() helper, and use it for the open-coded
> subtype == NVME_NQN_DISC checks in the host code to help
> maintain consistency and improve code readability.
>
> And while here, fix an error message to refer to the subsystem
> rather than the controller.
Not going to NAK it, but the helper feels a bit pointless to me.
Do you have any bigger plans with it?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: add nvme_is_disc_subsys() helper
2026-10-28 14:58 ` Christoph Hellwig
@ 2026-10-28 15:34 ` Martin George
2026-10-28 15:36 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Martin George @ 2026-10-28 15:34 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-nvme, kbusch, sagi
On Wed, 2026-10-28 at 15:58 +0100, Christoph Hellwig wrote:
> On Thu, Oct 22, 2026 at 01:01:44PM +0530, Martin George wrote:
> > Mirror the target's nvmet_is_disc_subsys() with a host-side
> > nvme_is_disc_subsys() helper, and use it for the open-coded
> > subtype == NVME_NQN_DISC checks in the host code to help
> > maintain consistency and improve code readability.
> >
> > And while here, fix an error message to refer to the subsystem
> > rather than the controller.
>
> Not going to NAK it, but the helper feels a bit pointless to me.
> Do you have any bigger plans with it?
>
No bigger plans - it's just a small cleanup. Mainly two things:
- Consistency with the target, which already has something similar
- It folds the open-coded discovery subtype checks into one self-
documenting helper for current & future use.
So a minor net improvement rather than a prerequisite for anything.
-Martin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: add nvme_is_disc_subsys() helper
2026-10-28 15:34 ` Martin George
@ 2026-10-28 15:36 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-10-28 15:36 UTC (permalink / raw)
To: Martin George; +Cc: Christoph Hellwig, linux-nvme, kbusch, sagi
On Wed, Oct 28, 2026 at 09:04:03PM +0530, Martin George wrote:
> No bigger plans - it's just a small cleanup. Mainly two things:
>
> - Consistency with the target, which already has something similar
> - It folds the open-coded discovery subtype checks into one self-
> documenting helper for current & future use.
>
> So a minor net improvement rather than a prerequisite for anything.
Not sure a helper is more self-documenting than a field check.
I don't really care strongly, but this feels a bit like churn without
a real purpose to me.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-28 15:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22 7:31 [PATCH] nvme: add nvme_is_disc_subsys() helper Martin George
2026-10-28 14:58 ` Christoph Hellwig
2026-10-28 15:34 ` Martin George
2026-10-28 15:36 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox