Linux-NVME Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] nvme-fc: shorten reconnect delay if possible for FC
@ 2020-10-16 21:29 James Smart
  2020-10-19 10:07 ` Hannes Reinecke
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Smart @ 2020-10-16 21:29 UTC (permalink / raw)
  To: linux-nvme; +Cc: James Smart

[-- Attachment #1.1: Type: text/plain, Size: 2225 bytes --]

We've had several complaints about a 10s reconnect delay (the default)
when there was an error while there is connectivity to a subsystem.
The max_reconnects and reconnect_delay are set in common code prior to
calling the transport to create the controller.

This change checks if the default reconnect delay is being used, and if
so, it adjusts it to a shorter period (2s) for the nvme-fc transport.
It does so by calculating the controller loss tmo window, changing the
value of the reconnect delay, and then recalculating the maximum number
of reconnect attempts allowed.

Signed-off-by: James Smart <james.smart@broadcom.com>
---
 drivers/nvme/host/fc.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 6352068c0c4a..1af7c6f358f5 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -26,6 +26,10 @@ enum nvme_fc_queue_flags {
 };
 
 #define NVME_FC_DEFAULT_DEV_LOSS_TMO	60	/* seconds */
+#define NVME_FC_DEFAULT_RECONNECT_TMO	2	/* delay between reconnects
+						 * when connected and a
+						 * connection failure.
+						 */
 
 struct nvme_fc_queue {
 	struct nvme_fc_ctrl	*ctrl;
@@ -3387,7 +3391,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 {
 	struct nvme_fc_ctrl *ctrl;
 	unsigned long flags;
-	int ret, idx;
+	int ret, idx, ctrl_loss_tmo;
 
 	if (!(rport->remoteport.port_role &
 	    (FC_PORT_ROLE_NVME_DISCOVERY | FC_PORT_ROLE_NVME_TARGET))) {
@@ -3413,6 +3417,19 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 		goto out_free_ctrl;
 	}
 
+	/*
+	 * if ctrl_loss_tmo is being enforced and the default reconnect delay
+	 * is being used, change to a shorter reconnect delay for FC.
+	 */
+	if (opts->max_reconnects != -1 &&
+	    opts->reconnect_delay == NVMF_DEF_RECONNECT_DELAY &&
+	    opts->reconnect_delay > NVME_FC_DEFAULT_RECONNECT_TMO) {
+		ctrl_loss_tmo = opts->max_reconnects * opts->reconnect_delay;
+		opts->reconnect_delay = NVME_FC_DEFAULT_RECONNECT_TMO;
+		opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
+						opts->reconnect_delay);
+	}
+
 	ctrl->ctrl.opts = opts;
 	ctrl->ctrl.nr_reconnects = 0;
 	if (lport->dev)
-- 
2.26.2


[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4163 bytes --]

[-- Attachment #2: Type: text/plain, Size: 158 bytes --]

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

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

* Re: [PATCH] nvme-fc: shorten reconnect delay if possible for FC
  2020-10-16 21:29 [PATCH] nvme-fc: shorten reconnect delay if possible for FC James Smart
@ 2020-10-19 10:07 ` Hannes Reinecke
  2020-10-19 14:59 ` Himanshu Madhani
  2020-10-22 13:37 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2020-10-19 10:07 UTC (permalink / raw)
  To: linux-nvme

On 10/16/20 11:29 PM, James Smart wrote:
> We've had several complaints about a 10s reconnect delay (the default)
> when there was an error while there is connectivity to a subsystem.
> The max_reconnects and reconnect_delay are set in common code prior to
> calling the transport to create the controller.
> 
> This change checks if the default reconnect delay is being used, and if
> so, it adjusts it to a shorter period (2s) for the nvme-fc transport.
> It does so by calculating the controller loss tmo window, changing the
> value of the reconnect delay, and then recalculating the maximum number
> of reconnect attempts allowed.
> 
> Signed-off-by: James Smart <james.smart@broadcom.com>
> ---
>   drivers/nvme/host/fc.c | 19 ++++++++++++++++++-
>   1 file changed, 18 insertions(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de

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] 4+ messages in thread

* Re: [PATCH] nvme-fc: shorten reconnect delay if possible for FC
  2020-10-16 21:29 [PATCH] nvme-fc: shorten reconnect delay if possible for FC James Smart
  2020-10-19 10:07 ` Hannes Reinecke
@ 2020-10-19 14:59 ` Himanshu Madhani
  2020-10-22 13:37 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Himanshu Madhani @ 2020-10-19 14:59 UTC (permalink / raw)
  To: James Smart; +Cc: linux-nvme



> On Oct 16, 2020, at 4:29 PM, James Smart <james.smart@broadcom.com> wrote:
> 
> We've had several complaints about a 10s reconnect delay (the default)
> when there was an error while there is connectivity to a subsystem.
> The max_reconnects and reconnect_delay are set in common code prior to
> calling the transport to create the controller.
> 
> This change checks if the default reconnect delay is being used, and if
> so, it adjusts it to a shorter period (2s) for the nvme-fc transport.
> It does so by calculating the controller loss tmo window, changing the
> value of the reconnect delay, and then recalculating the maximum number
> of reconnect attempts allowed.
> 
> Signed-off-by: James Smart <james.smart@broadcom.com>
> ---
> drivers/nvme/host/fc.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
> index 6352068c0c4a..1af7c6f358f5 100644
> --- a/drivers/nvme/host/fc.c
> +++ b/drivers/nvme/host/fc.c
> @@ -26,6 +26,10 @@ enum nvme_fc_queue_flags {
> };
> 
> #define NVME_FC_DEFAULT_DEV_LOSS_TMO	60	/* seconds */
> +#define NVME_FC_DEFAULT_RECONNECT_TMO	2	/* delay between reconnects
> +						 * when connected and a
> +						 * connection failure.
> +						 */
> 
> struct nvme_fc_queue {
> 	struct nvme_fc_ctrl	*ctrl;
> @@ -3387,7 +3391,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
> {
> 	struct nvme_fc_ctrl *ctrl;
> 	unsigned long flags;
> -	int ret, idx;
> +	int ret, idx, ctrl_loss_tmo;
> 
> 	if (!(rport->remoteport.port_role &
> 	    (FC_PORT_ROLE_NVME_DISCOVERY | FC_PORT_ROLE_NVME_TARGET))) {
> @@ -3413,6 +3417,19 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
> 		goto out_free_ctrl;
> 	}
> 
> +	/*
> +	 * if ctrl_loss_tmo is being enforced and the default reconnect delay
> +	 * is being used, change to a shorter reconnect delay for FC.
> +	 */
> +	if (opts->max_reconnects != -1 &&
> +	    opts->reconnect_delay == NVMF_DEF_RECONNECT_DELAY &&
> +	    opts->reconnect_delay > NVME_FC_DEFAULT_RECONNECT_TMO) {
> +		ctrl_loss_tmo = opts->max_reconnects * opts->reconnect_delay;
> +		opts->reconnect_delay = NVME_FC_DEFAULT_RECONNECT_TMO;
> +		opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
> +						opts->reconnect_delay);
> +	}
> +
> 	ctrl->ctrl.opts = opts;
> 	ctrl->ctrl.nr_reconnects = 0;
> 	if (lport->dev)
> -- 
> 2.26.2
> 
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme

Looks good.

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] 4+ messages in thread

* Re: [PATCH] nvme-fc: shorten reconnect delay if possible for FC
  2020-10-16 21:29 [PATCH] nvme-fc: shorten reconnect delay if possible for FC James Smart
  2020-10-19 10:07 ` Hannes Reinecke
  2020-10-19 14:59 ` Himanshu Madhani
@ 2020-10-22 13:37 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-10-22 13:37 UTC (permalink / raw)
  To: James Smart; +Cc: linux-nvme

Thanks,

applied.

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

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 21:29 [PATCH] nvme-fc: shorten reconnect delay if possible for FC James Smart
2020-10-19 10:07 ` Hannes Reinecke
2020-10-19 14:59 ` Himanshu Madhani
2020-10-22 13:37 ` Christoph Hellwig

Linux-NVME Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvme/0 linux-nvme/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvme linux-nvme/ https://lore.kernel.org/linux-nvme \
		linux-nvme@lists.infradead.org
	public-inbox-index linux-nvme

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-nvme


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git