All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrew Stellman" <bugs@stellman-greene.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme: requeue keep-alive work when a Keep Alive fails
Date: Wed, 02 Dec 2026 17:13:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-246312@kernel.org> (raw)
In-Reply-To: <20261202164944.49770-1-bugs@stellman-greene.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] nvme: zero-delay ka_work loop in nvme_keep_alive_end_io() when
  deadline is 0
- [High] nvme: nvme_keep_alive_end_io() re-arms ka_work after
  nvme_stop_keep_alive()
- [Medium] nvme: uncleared comp_seen on error in
  nvme_keep_alive_end_io() skips retry
--

commit df70267c1d3880bdae24c7ceb3c48d593ea8973c
Author: Andrew Stellman <astellman@stellman-greene.com>

nvme: requeue keep-alive work when a Keep Alive fails

This commit requeues ctrl->ka_work in nvme_keep_alive_end_io() when a
Keep Alive command completes with an error while the controller is in
NVME_CTRL_LIVE or NVME_CTRL_CONNECTING.

> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index f43582e5f6c4a..ca04ff0f437d6 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;
>  	}
>  

[Severity: High]
Can this spin in a zero-delay workqueue loop on nvme_wq if the request
fails before nvme_start_request() sets rq->deadline?

Keep Alive requests carry REQ_FAILFAST_DRIVER, so when ->queue_rq rejects
a command on an unquiesced non-ready admin queue via
nvme_fail_nonready_command() (for example in nvme_tcp_queue_rq() after
nvme_tcp_complete_timed_out() stops queue 0 while in
NVME_CTRL_CONNECTING), the request completes immediately with
rq->deadline still 0.  nvme_keep_alive_end_io() then computes rtt as
jiffies + rq->timeout, logs an unratelimited warning, sets delay = 0, and
requeues ctrl->ka_work with a delay of 0.

[Severity: High]
Can this re-arm ctrl->ka_work after nvme_stop_keep_alive() has already
returned during admin queue teardown in NVME_CTRL_CONNECTING?

In nvme_tcp_setup_ctrl() and nvme_rdma_setup_ctrl(), the destroy_admin
error path (as well as the TLS secure concatenation admin queue restart)
calls nvme_stop_keep_alive() before tearing down the admin queue:

drivers/nvme/host/tcp.c:nvme_tcp_setup_ctrl() {
    ...
destroy_admin:
	nvme_stop_keep_alive(ctrl);
	nvme_tcp_teardown_admin_queue(ctrl, new);
	return ret;
}

If a Keep Alive request is already in flight when nvme_stop_keep_alive()
runs, cancel_delayed_work_sync(&ctrl->ka_work) returns while the request
is still outstanding.  nvme_tcp_teardown_admin_queue() then calls
nvme_cancel_admin_tagset(), completing the request with
NVME_SC_HOST_ABORTED_CMD while ctrl->state is still NVME_CTRL_CONNECTING,
which now queues ctrl->ka_work again on the torn-down admin queue.

[Severity: Medium]
Should the error path also clear ctrl->comp_seen (or update
ctrl->ka_last_check_time) before requeueing ctrl->ka_work?

When the Keep Alive request completes with an error, __nvme_complete_rq()
still sets ctrl->comp_seen = true because rq->deadline - rq->timeout >=
ctrl->ka_last_check_time:

drivers/nvme/host/core.c:__nvme_complete_rq() {
    ...
	if (ctrl->kas &&
	    req->deadline - req->timeout >= ctrl->ka_last_check_time)
		ctrl->comp_seen = true;
    ...
}

Returning before ctrl->comp_seen = false leaves comp_seen set on
controllers with NVME_CTRL_ATTR_TBKAS enabled, so the next run of
nvme_keep_alive_work() treats the failed Keep Alive completion itself as
I/O traffic, skips sending a retry, and defers for another period, which
can still let the target's keep-alive timer expire.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202164944.49770-1-bugs@stellman-greene.com?part=1


  reply	other threads:[~2026-12-02 17:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 16:49 [PATCH] nvme: requeue keep-alive work when a Keep Alive fails Andrew Stellman
2026-12-02 17:13 ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-12-02 16:37 Andrew Stellman
2026-12-02 17:04 ` sashiko-bot

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=sashiko-outbox-246312@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bugs@stellman-greene.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.