linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet: avoid queuing keep-alive timer if it is disabled
@ 2021-04-15  9:05 Hou Pu
  2021-04-15 20:17 ` Chaitanya Kulkarni
  0 siblings, 1 reply; 3+ messages in thread
From: Hou Pu @ 2021-04-15  9:05 UTC (permalink / raw)
  To: sagi, hch, chaitanya.kulkarni; +Cc: linux-nvme, houpu.main

Issue following command:
nvme set-feature -f 0xf -v 0 /dev/nvme1n1 # disable keep-alive timer
nvme admin-passthru -o 0x18 /dev/nvme1n1  # send keep-alive command
will make keep-alive timer fired and thus delete the controller like
bellowing:

[247459.907635] nvmet: ctrl 1 keep-alive timer (0 seconds) expired!
[247459.930294] nvmet: ctrl 1 fatal error occurred!

Avoid this by not queuing delayed keep-alive if it is disabled when
keep-alive command is received from the admin queue.

Signed-off-by: Hou Pu <houpu.main@gmail.com>
---
 drivers/nvme/target/admin-cmd.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index f4cc32674edd..b8a33d1506ba 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -926,8 +926,12 @@ void nvmet_execute_keep_alive(struct nvmet_req *req)
 	pr_debug("ctrl %d update keep-alive timer for %d secs\n",
 		ctrl->cntlid, ctrl->kato);
 
-	mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
-	nvmet_req_complete(req, 0);
+	if (ctrl->kato) {
+		mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
+		nvmet_req_complete(req, 0);
+		return;
+	}
+	nvmet_req_complete(req, NVME_SC_KA_TIMEOUT_INVALID);
 }
 
 u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
-- 
2.28.0


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-16  2:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15  9:05 [PATCH] nvmet: avoid queuing keep-alive timer if it is disabled Hou Pu
2021-04-15 20:17 ` Chaitanya Kulkarni
2021-04-16  2:48   ` Hou Pu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).