nvme: avoid "(efault)" from nvme_sysfs_show_subsysnqn()
PATCH v2 1/1 nvme: avoid "(efault)" from nvme_sysfs_show_subsysnqn()
From: Martin Wilck <[email protected]>
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.
--- drivers/nvme/host/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +7 -1
@@ -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);
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 11 lines · On 2/1/21 17:00, [email protected] wrote:
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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 ifctrl->subsysisn't initialized yet.Signed-off-by Martin Wilck <[email protected]>
Please add the version history from next time, as it helps others to review the patch easily than the first-reviewer.
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 9 lines · On Tue, Feb 02, 2021 at 01:59:51AM +0100, [email protected] wrote:
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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 ifctrl->subsysisn't initialized yet.
This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
In other wwords - I think we should remove the cdev_device_add from nvme_init_ctrl to nvme_start_ctrl (+ any error handling changes resulting from that).
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 11 lines
Quoted 10 lines
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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 ifctrl->subsysisn't initialized yet.
Quoted 6 lines
This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
In other wwords - I think we should remove the
cdev_device_addfromnvme_init_ctrltonvme_start_ctrl(+ any error handling changes resulting from that).
Maybe move it to nvme_init_identify? nvme_start_ctrl is after I/O queues were created.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · On Tue, Feb 02, 2021 at 01:59:51AM +0100, [email protected] wrote:
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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.
Quoted 5 lines
Quoted 2 lines
Fix it by returning the
nvmf_ctrl_options' subsysnqn attribute ifctrl->subsysisn't initialized yet.This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
I don't follow. What's wrong with a "connecting" controller device in sysfs?
Controllers can loose connectivity any time. What's the difference between a controller that is reconnecting after a connection loss and a freshly created controller that's just not live yet? You wouldn't delete the former from sysfs, I suppose.
From the user space point of view, it's the same, a controller device that is not in usable state. I don't see a general problem with that. Seeing a controller appear in connecting state might actually be useful for user space.
The subsysnqn attribute is correct for controllers that were once connected and lost connectivity. My patch was only intended to fix the "just created and never connected" case, where it is not, nothing more.
Regards
Martin
Quoted 5 lines
In other wwords - I think we should remove the
cdev_device_addfromnvme_init_ctrltonvme_start_ctrl(+ any error handling changes resulting from that).
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 10 lines · Martin Wilck
Quoted 2 lines
This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
I don't follow. What's wrong with a "connecting" controller device in sysfs?
Controllers can loose connectivity any time. What's the difference between a controller that is reconnecting after a connection loss and a freshly created controller that's just not live yet? You wouldn't delete the former from sysfs, I suppose.
What is wrong is that we should only add the device and thus send the uevent notifcations when the device is fully set up.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerQuoted 23 lines · Martin Wilck
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · On Tue, Feb 02, 2021 at 01:59:51AM +0100, [email protected] wrote:
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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.Quoted 5 lines
Quoted 2 lines
Fix it by returning the
nvmf_ctrl_options' subsysnqn attribute ifctrl->subsysisn't initialized yet.This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
I don't follow. What's wrong with a "connecting" controller device in sysfs?
Controllers can loose connectivity any time. What's the difference between a controller that is reconnecting after a connection loss and a freshly created controller that's just not live yet? You wouldn't delete the former from sysfs, I suppose.
Quoted 8 lines
From the user space point of view, it's the same, a controller device that is not in usable state. I don't see a general problem with that. Seeing a controller appear in connecting state might actually be useful for user space.
The subsysnqn attribute is correct for controllers that were once connected and lost connectivity. My patch was only intended to fix the "just created and never connected" case, where it is not, nothing more.
I think Christoph is suggesting just wait until we have all the properties the driver exports rather than specifically exporting only during a 'live' state. Something like this (untested) should do the trick:
---
drivers/nvme/host/core.c +3 -6
@@ -3069,6 +3069,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)if (ret) goto out_free; + ret =cdev_device_add (&ctrl->cdev, ctrl->device); +if (ret) + goto out_free;/* * Check for quirks. Quirk can depend on firmware version, * so, in principle, the set of quirks present can change
@@ -4545,9 +4548,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,nvme_get_ctrl (ctrl);cdev_init (&ctrl->cdev, &nvme_dev_fops); ctrl->cdev.owner = ops->module; - ret =cdev_device_add (&ctrl->cdev, ctrl->device); -if (ret) - goto out_free_name;/* * Initialize latency tolerance controls. The sysfs files won't
@@ -4560,9 +4560,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,nvme_fault_inject_init (&ctrl->fault_inject,dev_name (ctrl->device));return 0 ; -out_free_name: -nvme_put_ctrl (ctrl); -kfree_const (ctrl->device->kobj.name); out_release_instance:ida_simple_remove (&nvme_instance_ida, ctrl->instance); out:
--
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 44 lines · Keith Busch
Quoted 23 lines · Martin Wilck
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · On Tue, Feb 02, 2021 at 01:59:51AM +0100, [email protected] wrote:
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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.Quoted 5 lines
Quoted 2 lines
Fix it by returning the
nvmf_ctrl_options' subsysnqn attribute ifctrl->subsysisn't initialized yet.This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
I don't follow. What's wrong with a "connecting" controller device in sysfs?
Controllers can loose connectivity any time. What's the difference between a controller that is reconnecting after a connection loss and a freshly created controller that's just not live yet? You wouldn't delete the former from sysfs, I suppose.
Quoted 8 lines
From the user space point of view, it's the same, a controller device
that is not in usable state. I don't see a general problem with that. Seeing a controller appear in connecting state might actually be useful for user space.The subsysnqn attribute is correct for controllers that were once connected and lost connectivity. My patch was only intended to fix the "just created and never connected" case, where it is not, nothing more.
I think Christoph is suggesting just wait until we have all the properties the driver exports rather than specifically exporting only during a 'live' state. Something like this (untested) should do the trick:
---
drivers/nvme/host/core.c +0
-0
drivers/nvme/host/core.c int nvme_init_identify(struct nvme_ctrl *ctrl) · line 3074
Quoted 6 lines
drivers/nvme/host/core.c +3
-0@@ -3069,6 +3069,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)if (ret) goto out_free; + ret =cdev_device_add (&ctrl->cdev, ctrl->device); +if (ret) + goto out_free;
This happens on every reset, we should probably just do this once?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerQuoted 41 lines · Sagi Grimberg
Quoted 38 lines · Keith Busch
Quoted 23 lines · Martin Wilck
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · On Tue, Feb 02, 2021 at 01:59:51AM +0100, [email protected] wrote:
From: Martin Wilck <[email protected]>
While a controller is still connecting,
ctrl->subsysis 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.Quoted 5 lines
Quoted 2 lines
Fix it by returning the
nvmf_ctrl_options' subsysnqn attribute ifctrl->subsysisn't initialized yet.This is just papering over symptoms. We should not be sending events or display sysfs files until the controlle is live.
I don't follow. What's wrong with a "connecting" controller device in sysfs?
Controllers can loose connectivity any time. What's the difference between a controller that is reconnecting after a connection loss and a freshly created controller that's just not live yet? You wouldn't delete the former from sysfs, I suppose.
Quoted 8 lines
From the user space point of view, it's the same, a controller device
that is not in usable state. I don't see a general problem with that. Seeing a controller appear in connecting state might actually be useful for user space.The subsysnqn attribute is correct for controllers that were once connected and lost connectivity. My patch was only intended to fix the "just created and never connected" case, where it is not, nothing more.
I think Christoph is suggesting just wait until we have all the properties the driver exports rather than specifically exporting only during a 'live' state. Something like this (untested) should do the trick:
Quoted 13 lines
drivers/nvme/host/core.c int nvme_init_identify(struct nvme_ctrl *ctrl) · line 3073
Quoted 11 lines
---
drivers/nvme/host/core.c +3
-0@@ -3069,6 +3069,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)if (ret) goto out_free; + ret =cdev_device_add (&ctrl->cdev, ctrl->device); +if (ret) + goto out_free;This happens on every reset, we should probably just do this once?
Right, and while the function is invoked on each reset, the above code sequence happens only once. You can't immediately tell from looking at the diff, but it's in the 'if (!ctrl->identified)' code block.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 20 lines
Quoted 6 lines
Quoted 6 lines
I think Christoph is suggesting just wait until we have all the properties the driver exports rather than specifically exporting only during a 'live' state. Something like this (untested) should do the trick:
Quoted 13 lines
drivers/nvme/host/core.c int nvme_init_identify(struct nvme_ctrl *ctrl) · line 3073
Quoted 11 lines
---
drivers/nvme/host/core.c +3
-0@@ -3069,6 +3069,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)if (ret) goto out_free; + ret =cdev_device_add (&ctrl->cdev, ctrl->device); +if (ret) + goto out_free;This happens on every reset, we should probably just do this once?
Quoted 3 lines
Right, and while the function is invoked on each reset, the above code sequence happens only once. You can't immediately tell from looking at the diff, but it's in the 'if (!ctrl->identified)' code block.
Yea, you're right...
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme