Skip to content

Commit f25f8ef

Browse files
hreineckeChristoph Hellwig
authored andcommitted
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. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Himanshu Madhani <[email protected]> Reviewed-by: James Smart <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 3596a06 commit f25f8ef

File tree

1 file changed

+17
-8
lines changed
  • drivers/nvme/host

1 file changed

+17
-8
lines changed

drivers/nvme/host/fc.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,13 +3107,15 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31073107
if (ctrl->ctrl.icdoff) {
31083108
dev_err(ctrl->ctrl.device, "icdoff %d is not supported!\n",
31093109
ctrl->ctrl.icdoff);
3110+
ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
31103111
goto out_disconnect_admin_queue;
31113112
}
31123113

31133114
/* FC-NVME supports normal SGL Data Block Descriptors */
31143115
if (!(ctrl->ctrl.sgls & ((1 << 0) | (1 << 1)))) {
31153116
dev_err(ctrl->ctrl.device,
31163117
"Mandatory sgls are not supported!\n");
3118+
ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
31173119
goto out_disconnect_admin_queue;
31183120
}
31193121

@@ -3280,11 +3282,13 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
32803282
if (ctrl->ctrl.state != NVME_CTRL_CONNECTING)
32813283
return;
32823284

3283-
if (portptr->port_state == FC_OBJSTATE_ONLINE)
3285+
if (portptr->port_state == FC_OBJSTATE_ONLINE) {
32843286
dev_info(ctrl->ctrl.device,
32853287
"NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n",
32863288
ctrl->cnum, status);
3287-
else if (time_after_eq(jiffies, rport->dev_loss_end))
3289+
if (status > 0 && (status & NVME_SC_DNR))
3290+
recon = false;
3291+
} else if (time_after_eq(jiffies, rport->dev_loss_end))
32883292
recon = false;
32893293

32903294
if (recon && nvmf_should_reconnect(&ctrl->ctrl)) {
@@ -3298,12 +3302,17 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
32983302

32993303
queue_delayed_work(nvme_wq, &ctrl->connect_work, recon_delay);
33003304
} else {
3301-
if (portptr->port_state == FC_OBJSTATE_ONLINE)
3302-
dev_warn(ctrl->ctrl.device,
3303-
"NVME-FC{%d}: Max reconnect attempts (%d) "
3304-
"reached.\n",
3305-
ctrl->cnum, ctrl->ctrl.nr_reconnects);
3306-
else
3305+
if (portptr->port_state == FC_OBJSTATE_ONLINE) {
3306+
if (status > 0 && (status & NVME_SC_DNR))
3307+
dev_warn(ctrl->ctrl.device,
3308+
"NVME-FC{%d}: reconnect failure\n",
3309+
ctrl->cnum);
3310+
else
3311+
dev_warn(ctrl->ctrl.device,
3312+
"NVME-FC{%d}: Max reconnect attempts "
3313+
"(%d) reached.\n",
3314+
ctrl->cnum, ctrl->ctrl.nr_reconnects);
3315+
} else
33073316
dev_warn(ctrl->ctrl.device,
33083317
"NVME-FC{%d}: dev_loss_tmo (%d) expired "
33093318
"while waiting for remoteport connectivity.\n",

0 commit comments

Comments
 (0)