nvme/fc: Short-circuit reconnect retries
Subsystems (2)
PATCH 1/1 nvme/fc: Short-circuit reconnect retries
Returning an nvme status from nvme_fc_create_association() indicates that the association is established, and we should honour the DNR bit. If it's set a reconnect attempt will just return the same error, so we can short-circuit the reconnect attempts and fail the connection directly.
--- drivers/nvme/host/fc.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/nvme/host/fc.c +17 -8
@@ -3095,6 +3095,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)if (ctrl->ctrl.icdoff) {dev_err (ctrl->ctrl.device,"icdoff %d is not supported!\n" , ctrl->ctrl.icdoff); + ret =NVME_SC_INVALID_FIELD |NVME_SC_DNR ; goto out_disconnect_admin_queue; }
@@ -3102,6 +3103,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)if (!(ctrl->ctrl.sgls & ((1 <<0 ) | (1 <<1 )))) {dev_err (ctrl->ctrl.device,"Mandatory sgls are not supported!\n" ); + ret =NVME_SC_INVALID_FIELD |NVME_SC_DNR ; goto out_disconnect_admin_queue; }
@@ -3268,11 +3270,13 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)if (ctrl->ctrl.state !=NVME_CTRL_CONNECTING )return ; -if (portptr->port_state ==FC_OBJSTATE_ONLINE ) +if (portptr->port_state ==FC_OBJSTATE_ONLINE ) {dev_info (ctrl->ctrl.device,"NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n" , ctrl->cnum, status); -else if (time_after_eq (jiffies, rport->dev_loss_end)) +if (status >0 && (status &NVME_SC_DNR )) + recon = false; + }else if (time_after_eq (jiffies, rport->dev_loss_end)) recon = false;if (recon &&nvmf_should_reconnect (&ctrl->ctrl)) {
@@ -3286,12 +3290,17 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)queue_delayed_work (nvme_wq, &ctrl->connect_work, recon_delay); }else { -if (portptr->port_state ==FC_OBJSTATE_ONLINE ) -dev_warn (ctrl->ctrl.device, -"NVME-FC{%d}: Max reconnect attempts (%d) " -"reached.\n" , - ctrl->cnum, ctrl->ctrl.nr_reconnects); -else +if (portptr->port_state ==FC_OBJSTATE_ONLINE ) { +if (status >0 && (status &NVME_SC_DNR )) +dev_warn (ctrl->ctrl.device, +"NVME-FC{%d}: reconnect failure\n" , + ctrl->cnum); +else +dev_warn (ctrl->ctrl.device, +"NVME-FC{%d}: Max reconnect attempts " +"(%d) reached.\n" , + ctrl->cnum, ctrl->ctrl.nr_reconnects); + }else dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: dev_loss_tmo (%d) expired " "while waiting for remoteport connectivity.\n",
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 62 lines · Hannes Reinecke
Returning an nvme status from
nvme_fc_create_association()indicates that the association is established, and we should honour the DNR bit. If it's set a reconnect attempt will just return the same error, so we can short-circuit the reconnect attempts and fail the connection directly.Signed-off-by Hannes Reinecke <[email protected]>--- drivers/nvme/host/fc.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)drivers/nvme/host/fc.c +10
-8@@ -3095,6 +3095,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)if (ctrl->ctrl.icdoff) {dev_err (ctrl->ctrl.device,"icdoff %d is not supported!\n" , ctrl->ctrl.icdoff); + ret =NVME_SC_INVALID_FIELD |NVME_SC_DNR ; goto out_disconnect_admin_queue; }@@ -3102,6 +3103,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)if (!(ctrl->ctrl.sgls & ((1 <<0 ) | (1 <<1 )))) {dev_err (ctrl->ctrl.device,"Mandatory sgls are not supported!\n" ); + ret =NVME_SC_INVALID_FIELD |NVME_SC_DNR ; goto out_disconnect_admin_queue; }@@ -3268,11 +3270,13 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)if (ctrl->ctrl.state !=NVME_CTRL_CONNECTING )return ; -if (portptr->port_state ==FC_OBJSTATE_ONLINE ) +if (portptr->port_state ==FC_OBJSTATE_ONLINE ) {dev_info (ctrl->ctrl.device,"NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n" , ctrl->cnum, status); -else if (time_after_eq (jiffies, rport->dev_loss_end)) +if (status >0 && (status &NVME_SC_DNR )) + recon = false; + }else if (time_after_eq (jiffies, rport->dev_loss_end)) recon = false;if (recon &&nvmf_should_reconnect (&ctrl->ctrl)) {@@ -3286,12 +3290,17 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)queue_delayed_work (nvme_wq, &ctrl->connect_work, recon_delay); }else { -if (portptr->port_state ==FC_OBJSTATE_ONLINE ) -dev_warn (ctrl->ctrl.device, -"NVME-FC{%d}: Max reconnect attempts (%d) " -"reached.\n" , - ctrl->cnum, ctrl->ctrl.nr_reconnects); -else +if (portptr->port_state ==FC_OBJSTATE_ONLINE ) { +if (status >0 && (status &NVME_SC_DNR )) + dev_warn(ctrl->ctrl.device, + "NVME-FC{%d}: reconnect failure\n",
drivers/nvme/host/fc.c nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) · line 3306
Quoted 10 lines
drivers/nvme/host/fc.c +7
-0+ ctrl->cnum); + else + dev_warn(ctrl->ctrl.device, +"NVME-FC{%d}: Max reconnect attempts " +"(%d) reached.\n" , + ctrl->cnum, ctrl->ctrl.nr_reconnects); + }else dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: dev_loss_tmo (%d) expired " "while waiting for remoteport connectivity.\n",
Looks Good to me.
Signature · 6 lines
Himanshu Madhani Oracle Linux Engineering _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 6 lines
if (recon && nvmf_should_reconnect(&ctrl->ctrl)) {drivers/nvme/host/fc.c +0
-0@@ -3286,12 +3290,17 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)queue_delayed_work (nvme_wq, &ctrl->connect_work, recon_delay); }else {
drivers/nvme/host/fc.c nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) · line 3296
Quoted 10 lines
drivers/nvme/host/fc.c +4
-6-if (portptr->port_state ==FC_OBJSTATE_ONLINE ) -dev_warn (ctrl->ctrl.device, -"NVME-FC{%d}: Max reconnect attempts (%d) " -"reached.\n" , - ctrl->cnum, ctrl->ctrl.nr_reconnects); -else +if (portptr->port_state ==FC_OBJSTATE_ONLINE ) { +if (status >0 && (status &NVME_SC_DNR )) + dev_warn(ctrl->ctrl.device, + "NVME-FC{%d}: reconnect failure\n",
Maybe worth to print the status here?
Otherwise looks good,
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
James Smart
Reviewed-byQuoted 19 lines · Sagi Grimberg
Quoted 6 lines
if (recon &&
nvmf_should_reconnect(&ctrl->ctrl)) {drivers/nvme/host/fc.c +0
-0@@ -3286,12 +3290,17 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); } else {drivers/nvme/host/fc.c nvme_fc_reconnect_or_delete(struct · line 3296
Quoted 10 lines
drivers/nvme/host/fc.c +4
-6- if (portptr->port_state == FC_OBJSTATE_ONLINE) - dev_warn(ctrl->ctrl.device, - "NVME-FC{%d}: Max reconnect attempts (%d) " - "reached.\n", - ctrl->cnum, ctrl->ctrl.nr_reconnects); - else + if (portptr->port_state == FC_OBJSTATE_ONLINE) { + if (status > 0 && (status & NVME_SC_DNR)) + dev_warn(ctrl->ctrl.device, + "NVME-FC{%d}: reconnect failure\n",Maybe worth to print the status here?
Quoted 3 lines
Otherwise looks good,
Reviewed-by Sagi Grimberg <[email protected]>
Agree with Sagi that the print should have the status.
-- james
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 19 lines · Sagi Grimberg
Quoted 6 lines
if (recon &&
nvmf_should_reconnect(&ctrl->ctrl)) {drivers/nvme/host/fc.c +0
-0@@ -3286,12 +3290,17 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay); } else {drivers/nvme/host/fc.c nvme_fc_reconnect_or_delete(struct · line 3296
Quoted 10 lines
drivers/nvme/host/fc.c +4
-6- if (portptr->port_state == FC_OBJSTATE_ONLINE) - dev_warn(ctrl->ctrl.device, - "NVME-FC{%d}: Max reconnect attempts (%d) " - "reached.\n", - ctrl->cnum, ctrl->ctrl.nr_reconnects); - else + if (portptr->port_state == FC_OBJSTATE_ONLINE) { + if (status > 0 && (status & NVME_SC_DNR)) + dev_warn(ctrl->ctrl.device, + "NVME-FC{%d}: reconnect failure\n",Maybe worth to print the status here?
Quoted 2 lines
Otherwise looks good,
Reviewed-by Sagi Grimberg <[email protected]>
No need, as it's already printed by the previous message some lines above this code :-)
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Thanks,
applied to nvme-5.13.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme