Skip to content

Commit aaeadd7

Browse files
sagigrimbergChristoph Hellwig
authored andcommitted
nvmet: fix false keep-alive timeout when a controller is torn down
Controller teardown flow may take some time in case it has many I/O queues, and the host may not send us keep-alive during this period. Hence reset the traffic based keep-alive timer so we don't trigger a controller teardown as a result of a keep-alive expiration. Reported-by: Yi Zhang <[email protected]> Signed-off-by: Sagi Grimberg <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Tested-by: Yi Zhang <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 25df1ac commit aaeadd7

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

drivers/nvme/target/core.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ static void nvmet_keep_alive_timer(struct work_struct *work)
388388
{
389389
struct nvmet_ctrl *ctrl = container_of(to_delayed_work(work),
390390
struct nvmet_ctrl, ka_work);
391-
bool cmd_seen = ctrl->cmd_seen;
391+
bool reset_tbkas = ctrl->reset_tbkas;
392392

393-
ctrl->cmd_seen = false;
394-
if (cmd_seen) {
393+
ctrl->reset_tbkas = false;
394+
if (reset_tbkas) {
395395
pr_debug("ctrl %d reschedule traffic based keep-alive timer\n",
396396
ctrl->cntlid);
397397
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
@@ -804,6 +804,13 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
804804
percpu_ref_exit(&sq->ref);
805805

806806
if (ctrl) {
807+
/*
808+
* The teardown flow may take some time, and the host may not
809+
* send us keep-alive during this period, hence reset the
810+
* traffic based keep-alive timer so we don't trigger a
811+
* controller teardown as a result of a keep-alive expiration.
812+
*/
813+
ctrl->reset_tbkas = true;
807814
nvmet_ctrl_put(ctrl);
808815
sq->ctrl = NULL; /* allows reusing the queue later */
809816
}
@@ -952,7 +959,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
952959
}
953960

954961
if (sq->ctrl)
955-
sq->ctrl->cmd_seen = true;
962+
sq->ctrl->reset_tbkas = true;
956963

957964
return true;
958965

drivers/nvme/target/nvmet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct nvmet_ctrl {
167167
struct nvmet_subsys *subsys;
168168
struct nvmet_sq **sqs;
169169

170-
bool cmd_seen;
170+
bool reset_tbkas;
171171

172172
struct mutex lock;
173173
u64 cap;

0 commit comments

Comments
 (0)