nvmet: don't check iosqes, iocqes for discovery controllers
Subsystems (2)
Sagi Grimberg
maintainerPATCH 1/2 nvmet: don't check iosqes, iocqes for discovery controllers
From the base spec, Figure 78:
"Controller Configuration, these fields are defined as parameters to configure an "I/O Controller (IOC)" and not to configure a "Discovery Controller (DC)".
...
"If the controller does not support I/O queues, then this field shall be read-only with a value of 0h"
Just have this check for I/O controllers.
--- drivers/nvme/target/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/nvme/target/core.c +8 -3
@@ -1107,9 +1107,14 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) {lockdep_assert_held (&ctrl->lock); -if (nvmet_cc_iosqes (ctrl->cc) !=NVME_NVM_IOSQES || -nvmet_cc_iocqes (ctrl->cc) !=NVME_NVM_IOCQES || -nvmet_cc_mps (ctrl->cc) !=0 || +if (!ctrl->subsys->type ==NVME_NQN_DISC && + (nvmet_cc_iosqes (ctrl->cc) !=NVME_NVM_IOSQES || +nvmet_cc_iocqes (ctrl->cc) !=NVME_NVM_IOCQES )) { + ctrl->csts =NVME_CSTS_CFS ; +return ; + } + +if (nvmet_cc_mps (ctrl->cc) !=0 ||nvmet_cc_ams (ctrl->cc) !=0 ||nvmet_cc_css (ctrl->cc) !=0 ) { ctrl->csts =NVME_CSTS_CFS ;
Signature · 7 lines
2.27.0 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH 2/2 nvme: don't set iosqes,iocqes for discovery controllers
From the base spec, Figure 78:
"Controller Configuration, these fields are defined as parameters to configure an "I/O Controller (IOC)" and not to configure a "Discovery Controller (DC)".
...
"If the controller does not support I/O queues, then this field shall be read-only with a value of 0h"
Set these only for I/O controllers.
--- drivers/nvme/host/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +7 -6
@@ -2443,6 +2443,11 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_disable_ctrl); +static inline bool nvme_discovery_ctrl (struct nvme_ctrl *ctrl) +{ +return ctrl->opts && ctrl->opts->discovery_nqn; +} +int nvme_enable_ctrl (struct nvme_ctrl *ctrl) {unsigned dev_page_min;
@@ -2468,7 +2473,8 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl) ctrl->ctrl_config =NVME_CC_CSS_NVM ; ctrl->ctrl_config |= (NVME_CTRL_PAGE_SHIFT -12 ) <<NVME_CC_MPS_SHIFT ; ctrl->ctrl_config |=NVME_CC_AMS_RR |NVME_CC_SHN_NONE ; - ctrl->ctrl_config |=NVME_CC_IOSQES |NVME_CC_IOCQES ; +if (!nvme_discovery_ctrl (ctrl)) + ctrl->ctrl_config |=NVME_CC_IOSQES |NVME_CC_IOCQES ; ctrl->ctrl_config |=NVME_CC_ENABLE ; ret = ctrl->ops->reg_write32 (ctrl,NVME_REG_CC , ctrl->ctrl_config);
@@ -2888,11 +2894,6 @@ static const struct attribute_group *nvme_subsys_attrs_groups[] = { NULL, }; -static inline bool nvme_discovery_ctrl (struct nvme_ctrl *ctrl) -{ -return ctrl->opts && ctrl->opts->discovery_nqn; -} -static bool nvme_validate_cntlid (struct nvme_subsystem *subsys,struct nvme_ctrl *ctrl,struct nvme_id_ctrl *id) {
Signature · 7 lines
2.27.0 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
So if we change this we break interaction with all old Linux (and maybe other?) targets.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
Quoted 2 lines
So if we change this we break interaction with all old Linux (and maybe other?) targets.
Well yes.. Do you think that we should do a retry in case it fails for backward compatibility?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
Quoted 5 lines · Sagi Grimberg
Quoted 2 lines
So if we change this we break interaction with all old Linux (and maybe other?) targets.
Well yes.. Do you think that we should do a retry in case it fails for backward compatibility?
I think we have to.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
So if we change this we break interaction with all old Linux (and maybe other?) targets.
Well yes.. Do you think that we should do a retry in case it fails for backward compatibility?
I think we have to.
The annoying thing here is that this issue will manifest in the host waiting on nvme_wait_ready for a long 7.5 seconds to understand that its maybe incompatible and re-attempt (nvme_enable_ctrl writes to cap and then polls CSTS)...
What I have now looks like:
--
drivers/nvme/host/core.c +6 -0
@@ -2457,8 +2457,14 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_disable_ctrl); +static inline bool nvme_discovery_ctrl (struct nvme_ctrl *ctrl) +{ +return ctrl->opts && ctrl->opts->discovery_nqn; +} +int nvme_enable_ctrl (struct nvme_ctrl *ctrl) { +bool compat_disc_ctrl_config = false;unsigned dev_page_min;int ret;
@@ -2482,13 +2488,33 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl) ctrl->ctrl_config =NVME_CC_CSS_NVM ; ctrl->ctrl_config |= (NVME_CTRL_PAGE_SHIFT - 12) <<
NVME_CC_MPS_SHIFT;
ctrl->ctrl_config |= NVME_CC_AMS_RR | NVME_CC_SHN_NONE;
- ctrl->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
+again:
+ if (!nvme_discovery_ctrl(ctrl) || compat_disc_ctrl_config)
+ ctrl->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
ctrl->ctrl_config |= NVME_CC_ENABLE;
ret = ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config);
if (ret)
return ret;- return nvme_wait_ready(ctrl, ctrl->cap, true);
+
+ ret = nvme_wait_ready(ctrl, ctrl->cap, true);
+ if (ret) {
+ if (!compat_disc_ctrl_config) {
+ pr_err("retrying...\n");
+ /*
+ * Backward compatibility work-around: some targets + * (i.e. older Linux targets) may incorrectly verify + * iosqes,iocqes are non-zero for discovery + * controllers. So in order not to break them, we + * attempt once again with the incorrect settings. + */
+ if (nvme_disable_ctrl(ctrl))
+ return ret;
+ compat_disc_ctrl_config = true;
+ goto again;
+ }
+ }
+ return ret;
}
EXPORT_SYMBOL_GPL(nvme_enable_ctrl);
@@ -2902,11 +2928,6 @@ static const struct attribute_group *nvme_subsys_attrs_groups[] = {
NULL,
};
-static inline bool nvme_discovery_ctrl(struct nvme_ctrl *ctrl) -{
- return ctrl->opts && ctrl->opts->discovery_nqn;
-}
-
static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
{
--
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
Quoted 6 lines · Sagi Grimberg
The annoying thing here is that this issue will manifest in the host waiting on
nvme_wait_readyfor a long 7.5 seconds to understand that its maybe incompatible and re-attempt (nvme_enable_ctrlwrites to cap and then polls CSTS)...What I have now looks like:
In terms of what to do about the retry this is what we'll have to do. That being said I think for existing controllers we should just stick to the existing wrong value, and only set the correct one for versions > 1.3. This isn't exactly correct, but probably causes the least harm. It will need an extensive comment, and maybe we need to add an option to override it if controllers show up that do not like the wrong value.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
Quoted 8 lines
Quoted 7 lines
The annoying thing here is that this issue will manifest in the host waiting on
nvme_wait_readyfor a long 7.5 seconds to understand that its maybe incompatible and re-attempt (nvme_enable_ctrlwrites to cap and then polls CSTS)...What I have now looks like:
Quoted 7 lines
In terms of what to do about the retry this is what we'll have to do. That being said I think for existing controllers we should just stick to the existing wrong value, and only set the correct one for versions > 1.3. This isn't exactly correct, but probably causes the least harm. It will need an extensive comment, and maybe we need to add an option to override it if controllers show up that do not like the wrong value.
So you suggest that we keep the retry w.a. but continue to send the wrong value in 1.3 or lower?
I personally think that this would be extremely confusing to users, if they do trip on this, but I agree that they are less likely to hit it because existing controllers obviously accept wrong values...
As for option to override. I really hate it.. What is the least exposure we can get for this but still allow the user to control this?
Wish we had a good and reliable quirk mechanism for fabrics...
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 2/2] nvme: don't set iosqes,iocqes for discovery controllers
Quoted 6 lines · Sagi Grimberg
So you suggest that we keep the retry w.a. but continue to send the wrong value in 1.3 or lower?
I personally think that this would be extremely confusing to users, if they do trip on this, but I agree that they are less likely to hit it because existing controllers obviously accept wrong values...
Yes. While I'd like to move to standards compliance as much as possible, introducing a long delay for every existing working setup is very counter productive.
Quoted 3 lines
As for option to override. I really hate it.. What is the least exposure we can get for this but still allow the user to control this?
We can of course still override it using an option.
Quoted 1 line
Wish we had a good and reliable quirk mechanism for fabrics...
We do, using the serial number. But that does not help for an issue during connection establishment.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 1/2] nvmet: don't check iosqes,iocqes for discovery controllers
In reply to Sagi Grimbergdrivers/nvme/target/core.c static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) · line 1110
Quoted 1 line · Sagi Grimberg
drivers/nvme/target/core.c +1
-0+ if (!ctrl->subsys->type == NVME_NQN_DISC &&
I think the normal way to write this would be a !=.
drivers/nvme/target/core.c static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) · line 1112
Quoted 2 lines
drivers/nvme/target/core.c +2
-0+ (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES || + nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES)) {
By the spec we'd need to check these are 0, but of course we'd break the existing Linux host. Maybe throw in a comment?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerRe: [PATCH 1/2] nvmet: don't check iosqes,iocqes for discovery controllers
Quoted 4 lines
drivers/nvme/target/core.c static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) · line 1110
Quoted 2 lines
drivers/nvme/target/core.c +1
-0+ if (!ctrl->subsys->type == NVME_NQN_DISC &&I think the normal way to write this would be a !=.
:)
Quoted 5 lines
drivers/nvme/target/core.c static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) · line 1112
Quoted 2 lines
drivers/nvme/target/core.c +2
-0+ (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES || + nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES)) {By the spec we'd need to check these are 0, but of course we'd break the existing Linux host. Maybe throw in a comment?
Sure, I'll add it.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme