Commit c09305ae authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Jens Axboe

nvmet: support for traffic based keep-alive

A controller that supports traffic based keep-alive can restart the keep
alive timer even when no keep-alive was not received in the kato period
as long as other admin or I/O commands were received.  For each command
set ctrl->cmd_seen to true, and when keep-alive timer expires, if any
commands were seen, resched ka_work instead of escalating to a fatal
error.
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6e3ca03e
...@@ -304,7 +304,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) ...@@ -304,7 +304,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
/* XXX: figure out what to do about RTD3R/RTD3 */ /* XXX: figure out what to do about RTD3R/RTD3 */
id->oaes = cpu_to_le32(NVMET_AEN_CFG_OPTIONAL); id->oaes = cpu_to_le32(NVMET_AEN_CFG_OPTIONAL);
id->ctratt = cpu_to_le32(NVME_CTRL_ATTR_HID_128_BIT); id->ctratt = cpu_to_le32(NVME_CTRL_ATTR_HID_128_BIT |
NVME_CTRL_ATTR_TBKAS);
id->oacs = 0; id->oacs = 0;
......
...@@ -299,6 +299,15 @@ static void nvmet_keep_alive_timer(struct work_struct *work) ...@@ -299,6 +299,15 @@ static void nvmet_keep_alive_timer(struct work_struct *work)
{ {
struct nvmet_ctrl *ctrl = container_of(to_delayed_work(work), struct nvmet_ctrl *ctrl = container_of(to_delayed_work(work),
struct nvmet_ctrl, ka_work); struct nvmet_ctrl, ka_work);
bool cmd_seen = ctrl->cmd_seen;
ctrl->cmd_seen = false;
if (cmd_seen) {
pr_debug("ctrl %d reschedule traffic based keep-alive timer\n",
ctrl->cntlid);
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
return;
}
pr_err("ctrl %d keep-alive timer (%d seconds) expired!\n", pr_err("ctrl %d keep-alive timer (%d seconds) expired!\n",
ctrl->cntlid, ctrl->kato); ctrl->cntlid, ctrl->kato);
...@@ -801,6 +810,9 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, ...@@ -801,6 +810,9 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
goto fail; goto fail;
} }
if (sq->ctrl)
sq->ctrl->cmd_seen = true;
return true; return true;
fail: fail:
......
...@@ -163,6 +163,8 @@ struct nvmet_ctrl { ...@@ -163,6 +163,8 @@ struct nvmet_ctrl {
struct nvmet_cq **cqs; struct nvmet_cq **cqs;
struct nvmet_sq **sqs; struct nvmet_sq **sqs;
bool cmd_seen;
struct mutex lock; struct mutex lock;
u64 cap; u64 cap;
u32 cc; u32 cc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment