Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: requeue keep-alive work when a Keep Alive fails
@ 2026-12-02 16:37 Andrew Stellman
  2026-12-02 17:04 ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Stellman @ 2026-12-02 16:37 UTC (permalink / raw)
  To: Keith Busch, Christoph Hellwig, Sagi Grimberg
  Cc: Jens Axboe, linux-nvme, linux-kernel

From: Andrew Stellman <astellman@stellman-greene.com>

When a Keep Alive command completes with an error,
nvme_keep_alive_end_io() logs it and returns without requeueing
ctrl->ka_work, so no further Keep Alives are sent while the controller
stays LIVE. With a test-only nvmet change that failed one Keep Alive,
the target's keep-alive timer expired.

Requeue ka_work on the error path under the same LIVE/CONNECTING check
the success path uses.

Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook).

Fixes: 038bd4cb6766 ("nvme: add keep-alive support")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
This changes behavior: after a Keep Alive error in LIVE or CONNECTING,
Keep Alives now continue instead of stopping.

Tested on mainline 7.4.0-rc5 (19cc08c1a6a6) in arm64 QEMU with KASAN,
NVMe/TCP loopback to nvmet with keep_alive_tmo=6, using a test-only
nvmet change that fails one Keep Alive with Internal Error/DNR. Without
the patch no further Keep Alive was sent before the target's keep-alive
timer expired; with it the next Keep Alive arrived about 3 seconds later
and the controller stayed LIVE. No other status, transport or the
CONNECTING case was tested.

I found this issue running Quality Playbook with Claude Opus 5.5. The
fix was drafted with OpenAI GPT-6 (Codex), and this changelog with
OpenAI GPT-6 (Codex) and Claude Sonnet 5.5; both were reviewed by me. A
reproducer is available on request.

 drivers/nvme/host/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f43582e5f6c4..ca04ff0f437d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1387,6 +1387,8 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
 		dev_err(ctrl->device,
 			"failed nvme_keep_alive_end_io error=%d\n",
 				status);
+		if (state == NVME_CTRL_LIVE || state == NVME_CTRL_CONNECTING)
+			queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
 		return RQ_END_IO_NONE;
 	}
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] nvme: requeue keep-alive work when a Keep Alive fails
@ 2026-12-02 16:49 Andrew Stellman
  2026-12-02 17:13 ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Stellman @ 2026-12-02 16:49 UTC (permalink / raw)
  To: Keith Busch, Christoph Hellwig, Sagi Grimberg
  Cc: Jens Axboe, linux-nvme, linux-kernel

From: Andrew Stellman <astellman@stellman-greene.com>

When a Keep Alive command completes with an error,
nvme_keep_alive_end_io() logs it and returns without requeueing
ctrl->ka_work, so no further Keep Alives are sent while the controller
stays LIVE. With a test-only nvmet change that failed one Keep Alive,
the target's keep-alive timer expired.

Requeue ka_work on the error path under the same LIVE/CONNECTING check
the success path uses.

Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook).

Fixes: 038bd4cb6766 ("nvme: add keep-alive support")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
This changes behavior: after a Keep Alive error in LIVE or CONNECTING,
Keep Alives now continue instead of stopping.

Tested on mainline 7.4.0-rc5 (19cc08c1a6a6) in arm64 QEMU with KASAN,
NVMe/TCP loopback to nvmet with keep_alive_tmo=6, using a test-only
nvmet change that fails one Keep Alive with Internal Error/DNR. Without
the patch no further Keep Alive was sent before the target's keep-alive
timer expired; with it the next Keep Alive arrived about 3 seconds later
and the controller stayed LIVE. No other status, transport or the
CONNECTING case was tested.

I found this issue running Quality Playbook with Claude Opus 5.5. The
fix was drafted with OpenAI GPT-6 (Codex), and this changelog with
OpenAI GPT-6 (Codex) and Claude Sonnet 5.5; both were reviewed by me. A
reproducer is available on request.

 drivers/nvme/host/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f43582e5f6c4..ca04ff0f437d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1387,6 +1387,8 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
 		dev_err(ctrl->device,
 			"failed nvme_keep_alive_end_io error=%d\n",
 				status);
+		if (state == NVME_CTRL_LIVE || state == NVME_CTRL_CONNECTING)
+			queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
 		return RQ_END_IO_NONE;
 	}
 
-- 
2.53.0



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

end of thread, other threads:[~2026-12-02 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 16:37 [PATCH] nvme: requeue keep-alive work when a Keep Alive fails Andrew Stellman
2026-12-02 17:04 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-12-02 16:49 Andrew Stellman
2026-12-02 17:13 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox