Skip to content

Commit f673714

Browse files
James SmartChristoph Hellwig
authored andcommitted
nvme-fc: shorten reconnect delay if possible for FC
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> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 88e837e commit f673714

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

  • drivers/nvme/host

drivers/nvme/host/fc.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ enum nvme_fc_queue_flags {
2626
};
2727

2828
#define NVME_FC_DEFAULT_DEV_LOSS_TMO 60 /* seconds */
29+
#define NVME_FC_DEFAULT_RECONNECT_TMO 2 /* delay between reconnects
30+
* when connected and a
31+
* connection failure.
32+
*/
2933

3034
struct nvme_fc_queue {
3135
struct nvme_fc_ctrl *ctrl;
@@ -3436,7 +3440,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
34363440
{
34373441
struct nvme_fc_ctrl *ctrl;
34383442
unsigned long flags;
3439-
int ret, idx;
3443+
int ret, idx, ctrl_loss_tmo;
34403444

34413445
if (!(rport->remoteport.port_role &
34423446
(FC_PORT_ROLE_NVME_DISCOVERY | FC_PORT_ROLE_NVME_TARGET))) {
@@ -3462,6 +3466,19 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
34623466
goto out_free_ctrl;
34633467
}
34643468

3469+
/*
3470+
* if ctrl_loss_tmo is being enforced and the default reconnect delay
3471+
* is being used, change to a shorter reconnect delay for FC.
3472+
*/
3473+
if (opts->max_reconnects != -1 &&
3474+
opts->reconnect_delay == NVMF_DEF_RECONNECT_DELAY &&
3475+
opts->reconnect_delay > NVME_FC_DEFAULT_RECONNECT_TMO) {
3476+
ctrl_loss_tmo = opts->max_reconnects * opts->reconnect_delay;
3477+
opts->reconnect_delay = NVME_FC_DEFAULT_RECONNECT_TMO;
3478+
opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
3479+
opts->reconnect_delay);
3480+
}
3481+
34653482
ctrl->ctrl.opts = opts;
34663483
ctrl->ctrl.nr_reconnects = 0;
34673484
if (lport->dev)

0 commit comments

Comments
 (0)