From: mwilck@suse.com
To: Sagi Grimberg <sagi@grimberg.me>, Christoph Hellwig <hch@lst.de>,
Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Cc: Keith Busch <kbusch@kernel.org>, Hannes Reinecke <hare@suse.de>,
linux-nvme@lists.infradead.org, Martin Wilck <mwilck@suse.com>
Subject: [PATCH v2] nvme: avoid "(efault)" from nvme_sysfs_show_subsysnqn()
Date: Tue, 2 Feb 2021 01:59:51 +0100 [thread overview]
Message-ID: <20210202005951.26614-1-mwilck@suse.com> (raw)
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
next reply other threads:[~2021-02-02 1:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 0:59 mwilck [this message]
2021-02-02 1:34 ` [PATCH v2] nvme: avoid "(efault)" from nvme_sysfs_show_subsysnqn() 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
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=20210202005951.26614-1-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=hare@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox