mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Stellman <bugs@stellman-greene.com>
To: Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] nvme: requeue keep-alive work when a Keep Alive fails
Date: Wed,  2 Dec 2026 14:22:36 -0500	[thread overview]
Message-ID: <20261202192236.88068-1-bugs@stellman-greene.com> (raw)

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

When a Keep Alive fails, nvme_keep_alive_end_io() returns without
queueing ka_work again, so no more Keep Alives get sent and the target's
keep-alive timer expires even though the controller is still LIVE. Fix
this by requeueing ka_work in LIVE with nvme_queue_keep_alive_work(), so
a failed Keep Alive gets retried after the normal delay.

Fixes: 038bd4cb6766 ("nvme: add keep-alive support")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
v2: requeue only in LIVE, with the normal delay, after Sashiko's review
of v1. A failed Keep Alive in CONNECTING still stops keep-alive, as it
does today.
v1: https://lore.kernel.org/r/20261202163728.48705-1-bugs@stellman-greene.com

Tested on mainline 19cc08c1a6a6 in arm64 QEMU with KASAN over NVMe/TCP
loopback with a test-only nvmet error: before the fix the target's
keep-alive timer expired, and with it another Keep Alive arrived first.

Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook) running Claude
Opus 5.5; the fix was drafted with OpenAI GPT-6 (Codex).

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..58bae0e85a01 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)
+			nvme_queue_keep_alive_work(ctrl);
 		return RQ_END_IO_NONE;
 	}
 
-- 
2.53.0


                 reply	other threads:[~2026-12-02 19:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202192236.88068-1-bugs@stellman-greene.com \
    --to=bugs@stellman-greene.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®