nvmet: avoid queuing keep-alive timer if it is disabled
Subsystems (2)
PATCH 1/1 nvmet: avoid queuing keep-alive timer if it is disabled
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.
--- drivers/nvme/target/admin-cmd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/target/admin-cmd.c +6 -2
@@ -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)
Signature · 7 lines
2.28.0 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Hou,
Quoted 14 lines · Hou Pu
--- drivers/nvme/target/admin-cmd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/nvme/target/admin-cmd.c +0
-2@@ -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 );
drivers/nvme/target/admin-cmd.c void nvmet_execute_keep_alive(struct nvmet_req *req)
Quoted 10 lines
drivers/nvme/target/admin-cmd.c +6
-1+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
I've validated that this behaviour does exists and this patch fixes that.Please add my :-
Also, please consider following on the top of this patch :-
(quoted diff) +0 -0
b/drivers/nvme/target/admin-cmd.c
index a892cd246783..3422d35b25a1 100644
drivers/nvme/target/admin-cmd.c +0 -0
@@ -1010,19 +1010,21 @@ void nvmet_execute_async_event(struct nvmet_req
*req)
void nvmet_execute_keep_alive(struct nvmet_req *req)
{
struct nvmet_ctrl *ctrl = req->sq->ctrl;+ u16 status = 0;
if (!nvmet_check_transfer_len(req, 0))
return;+ if (!ctrl->kato) {
+ status = NVME_SC_KA_TIMEOUT_INVALID;
+ goto out;
+ }
+
pr_debug("ctrl %d update keep-alive timer for %d secs\n",
ctrl->cntlid, ctrl->kato);
-
- 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); + mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
+out:
+ nvmet_req_complete(req, status);
}
u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 25 lines · Chaitanya Kulkarni
Hou,
Quoted 22 lines · Hou Pu
--- drivers/nvme/target/admin-cmd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/nvme/target/admin-cmd.c +6
-2@@ -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 ); }
Quoted 6 lines
drivers/nvme/target/admin-cmd.c void nvmet_execute_keep_alive(struct nvmet_req *req)
Quoted 2 lines
drivers/nvme/target/admin-cmd.c +0
-1u16 nvmet_parse_admin_cmd (struct nvmet_req *req) -- 2.28.0I've validated that this behaviour does exists and this patch fixes that.Please add my :-
Tested-by Chaitanya Kulkarni <[email protected]>
Thanks.
Quoted 2 lines
Also, please consider following on the top of this patch :-
Thanks. Changed in v2.
Quoted 36 lines
drivers/nvme/target/admin-cmd.c +9
-7@@ -1010,19 +1010,21 @@ void nvmet_execute_async_event(struct nvmet_req *req)void nvmet_execute_keep_alive (struct nvmet_req *req) {struct nvmet_ctrl *ctrl = req->sq->ctrl; +u16 status =0 ;if (!nvmet_check_transfer_len (req,0 ))return ; +if (!ctrl->kato) { + status =NVME_SC_KA_TIMEOUT_INVALID ; + goto out; + } +pr_debug ("ctrl %d update keep-alive timer for %d secs\n" , ctrl->cntlid, ctrl->kato); - -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 ); +mod_delayed_work (system_wq, &ctrl->ka_work, ctrl->kato *HZ ); +out: +nvmet_req_complete (req, status); }
Quoted 3 lines
u16
nvmet_parse_admin_cmd(struct nvmet_req *req)
Thanks,
Hou
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme