All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme/fc: Short-circuit reconnect retries
@ 2021-05-21  8:23 Hannes Reinecke
  2021-05-21 17:28 ` Himanshu Madhani
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hannes Reinecke @ 2021-05-21  8:23 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, James Smart, linux-nvme, 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 <hare@suse.de>
---
 drivers/nvme/host/fc.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index d9ab9e7871d0..b16acab5d8d8 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -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",
-- 
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] 6+ messages in thread

* Re: [PATCH] nvme/fc: Short-circuit reconnect retries
  2021-05-21  8:23 [PATCH] nvme/fc: Short-circuit reconnect retries Hannes Reinecke
@ 2021-05-21 17:28 ` Himanshu Madhani
  2021-05-21 20:17 ` Sagi Grimberg
  2021-05-25  7:24 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Himanshu Madhani @ 2021-05-21 17:28 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, James Smart, linux-nvme



On 5/21/21 3:23 AM, Hannes Reinecke wrote:
> 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 <hare@suse.de>
> ---
>   drivers/nvme/host/fc.c | 25 +++++++++++++++++--------
>   1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
> index d9ab9e7871d0..b16acab5d8d8 100644
> --- a/drivers/nvme/host/fc.c
> +++ b/drivers/nvme/host/fc.c
> @@ -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",
> 

Looks Good to me.

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

-- 
Himanshu Madhani                                Oracle Linux Engineering

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

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

* Re: [PATCH] nvme/fc: Short-circuit reconnect retries
  2021-05-21  8:23 [PATCH] nvme/fc: Short-circuit reconnect retries Hannes Reinecke
  2021-05-21 17:28 ` Himanshu Madhani
@ 2021-05-21 20:17 ` Sagi Grimberg
  2021-05-21 20:48   ` James Smart
  2021-05-22  9:48   ` Hannes Reinecke
  2021-05-25  7:24 ` Christoph Hellwig
  2 siblings, 2 replies; 6+ messages in thread
From: Sagi Grimberg @ 2021-05-21 20:17 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig; +Cc: Keith Busch, James Smart, linux-nvme


>   	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",

Maybe worth to print the status here?

Otherwise looks good,
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

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

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

* Re: [PATCH] nvme/fc: Short-circuit reconnect retries
  2021-05-21 20:17 ` Sagi Grimberg
@ 2021-05-21 20:48   ` James Smart
  2021-05-22  9:48   ` Hannes Reinecke
  1 sibling, 0 replies; 6+ messages in thread
From: James Smart @ 2021-05-21 20:48 UTC (permalink / raw)
  To: Sagi Grimberg, Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, James Smart, linux-nvme

On 5/21/2021 1:17 PM, Sagi Grimberg wrote:
> 
>>       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",
> 
> Maybe worth to print the status here?
> 
> Otherwise looks good,
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> 

Agree with Sagi that the print should have the status.

Reviewed-by:  James Smart <jsmart2021@gmail.com>

-- james


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

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

* Re: [PATCH] nvme/fc: Short-circuit reconnect retries
  2021-05-21 20:17 ` Sagi Grimberg
  2021-05-21 20:48   ` James Smart
@ 2021-05-22  9:48   ` Hannes Reinecke
  1 sibling, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2021-05-22  9:48 UTC (permalink / raw)
  To: Sagi Grimberg, Christoph Hellwig; +Cc: Keith Busch, James Smart, linux-nvme

On 5/21/21 10:17 PM, Sagi Grimberg wrote:
> 
>>       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",
> 
> Maybe worth to print the status here?
> 
> Otherwise looks good,
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

No need, as it's already printed by the previous message some lines 
above this code :-)

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH] nvme/fc: Short-circuit reconnect retries
  2021-05-21  8:23 [PATCH] nvme/fc: Short-circuit reconnect retries Hannes Reinecke
  2021-05-21 17:28 ` Himanshu Madhani
  2021-05-21 20:17 ` Sagi Grimberg
@ 2021-05-25  7:24 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-05-25  7:24 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch, James Smart, linux-nvme

Thanks,

applied to nvme-5.13.

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

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

end of thread, other threads:[~2021-05-25  7:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21  8:23 [PATCH] nvme/fc: Short-circuit reconnect retries Hannes Reinecke
2021-05-21 17:28 ` Himanshu Madhani
2021-05-21 20:17 ` Sagi Grimberg
2021-05-21 20:48   ` James Smart
2021-05-22  9:48   ` Hannes Reinecke
2021-05-25  7:24 ` Christoph Hellwig

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.