All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvme: avoid "(efault)" from nvme_sysfs_show_subsysnqn()
@ 2021-02-02  0:59 mwilck
  2021-02-02  1:34 ` Chaitanya Kulkarni
  2021-02-02  7:58 ` Christoph Hellwig
  0 siblings, 2 replies; 10+ messages in thread
From: mwilck @ 2021-02-02  0:59 UTC (permalink / raw)
  To: Sagi Grimberg, Christoph Hellwig, Chaitanya Kulkarni
  Cc: Keith Busch, Hannes Reinecke, linux-nvme, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

While a controller is still connecting, ctrl->subsys is NULL and
thus reading the controller's "subsysnqn" sysfs attribute returns
"(efault)". This happens all the time when user space processes
"add" events for NVMe controller devices.

Fix it by returning the nvmf_ctrl_options' subsysnqn attribute
if ctrl->subsys isn't initialized yet.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 drivers/nvme/host/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f320273fc672..8b0fc4a07b31 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3538,8 +3538,14 @@ static ssize_t nvme_sysfs_show_subsysnqn(struct device *dev,
 					 char *buf)
 {
 	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+	char *subsysnqn = "unknown";
 
-	return snprintf(buf, PAGE_SIZE, "%s\n", ctrl->subsys->subnqn);
+	if (ctrl->subsys)
+		subsysnqn = ctrl->subsys->subnqn;
+	else if (ctrl->opts && ctrl->opts->subsysnqn)
+		subsysnqn = ctrl->opts->subsysnqn;
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", subsysnqn);
 }
 static DEVICE_ATTR(subsysnqn, S_IRUGO, nvme_sysfs_show_subsysnqn, NULL);
 
-- 
2.29.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

end of thread, other threads:[~2021-02-04  7:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02  0:59 [PATCH v2] nvme: avoid "(efault)" from nvme_sysfs_show_subsysnqn() mwilck
2021-02-02  1:34 ` Chaitanya Kulkarni
2021-02-02  7:58 ` Christoph Hellwig
2021-02-03 10:01   ` Sagi Grimberg
2021-02-03 12:31   ` Martin Wilck
2021-02-03 16:51     ` Christoph Hellwig
2021-02-03 16:52     ` Keith Busch
2021-02-03 22:19       ` Sagi Grimberg
2021-02-04  2:42         ` Keith Busch
2021-02-04  7:44           ` Sagi Grimberg

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.