Skip to content

Commit ac9b820

Browse files
James SmartChristoph Hellwig
authored andcommitted
nvme-fc: remove nvme_fc_terminate_io()
__nvme_fc_terminate_io() is now called by only 1 place, in reset_work. Consoldate and move the functionality of terminate_io into reset_work. In reset_work, rather than calling the create_association directly, schedule the connect work element to do its thing. After scheduling, flush the connect work element to continue with semantic of not returning until connect has been attempted at least once. Signed-off-by: James Smart <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 95ced8a commit ac9b820

File tree

1 file changed

+16
-33
lines changed
  • drivers/nvme/host

1 file changed

+16
-33
lines changed

drivers/nvme/host/fc.c

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,49 +3287,32 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
32873287
}
32883288

32893289
static void
3290-
__nvme_fc_terminate_io(struct nvme_fc_ctrl *ctrl)
3290+
nvme_fc_reset_ctrl_work(struct work_struct *work)
32913291
{
3292-
/*
3293-
* For any other state, kill the association. As this routine
3294-
* is a common io abort routine for resetting and such, after
3295-
* the association is terminated, ensure that the state is set
3296-
* to CONNECTING.
3297-
*/
3292+
struct nvme_fc_ctrl *ctrl =
3293+
container_of(work, struct nvme_fc_ctrl, ctrl.reset_work);
32983294

3299-
nvme_stop_keep_alive(&ctrl->ctrl);
3295+
nvme_stop_ctrl(&ctrl->ctrl);
33003296

33013297
/* will block will waiting for io to terminate */
33023298
nvme_fc_delete_association(ctrl);
33033299

3304-
if (ctrl->ctrl.state != NVME_CTRL_CONNECTING &&
3305-
!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
3300+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
33063301
dev_err(ctrl->ctrl.device,
33073302
"NVME-FC{%d}: error_recovery: Couldn't change state "
33083303
"to CONNECTING\n", ctrl->cnum);
3309-
}
3310-
3311-
static void
3312-
nvme_fc_reset_ctrl_work(struct work_struct *work)
3313-
{
3314-
struct nvme_fc_ctrl *ctrl =
3315-
container_of(work, struct nvme_fc_ctrl, ctrl.reset_work);
3316-
int ret;
3317-
3318-
__nvme_fc_terminate_io(ctrl);
33193304

3320-
nvme_stop_ctrl(&ctrl->ctrl);
3321-
3322-
if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE)
3323-
ret = nvme_fc_create_association(ctrl);
3324-
else
3325-
ret = -ENOTCONN;
3326-
3327-
if (ret)
3328-
nvme_fc_reconnect_or_delete(ctrl, ret);
3329-
else
3330-
dev_info(ctrl->ctrl.device,
3331-
"NVME-FC{%d}: controller reset complete\n",
3332-
ctrl->cnum);
3305+
if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE) {
3306+
if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) {
3307+
dev_err(ctrl->ctrl.device,
3308+
"NVME-FC{%d}: failed to schedule connect "
3309+
"after reset\n", ctrl->cnum);
3310+
} else {
3311+
flush_delayed_work(&ctrl->connect_work);
3312+
}
3313+
} else {
3314+
nvme_fc_reconnect_or_delete(ctrl, -ENOTCONN);
3315+
}
33333316
}
33343317

33353318

0 commit comments

Comments
 (0)