All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linjun Bao <meljbao@gmail.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: [PATCH] nvme: avoid missing db ring during reset
Date: Fri, 25 Apr 2025 20:01:45 +0800	[thread overview]
Message-ID: <fa04f3d5-56ff-62bb-0afd-ad94e961ddee@gmail.com> (raw)

During nvme reset, there is a rare case, when user admin cmd such
as smart-log and nvme_admin_create_sq from nvme_setup_io_queues
happen to in the same blk_mq dispatch list, and the user cmd is
the last one. nvme_admin_create_sq is dispatched first in
nvme_queue_rq(), nvme_write_sq_db() is called but immediately
returns without writing the doorbell because it's not masked
"last". The subsequent smart-log ioctl fails fast hitting
nvme_fail_nonready_cmd(), skipping both nvme_sq_copy_cmd() and
nvme_write_sq_db(), so no doorbell write ever occurs. The
nvme_admin_create_sq fails timeout finally.

The proposal is that do not treat user admin cmd during
RECONNECTING as non-ready, through it to the drive, thus no
doorbell missing happens in case above.

Signed-off-by: Linjun Bao <meljbao@gmail.com>
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3cc79817e4d7..fc550226ed77 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -750,7 +750,8 @@ bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
 	 * sequence. until the controller will be LIVE, fail with
 	 * BLK_STS_RESOURCE so that they will be rescheduled.
 	 */
-	if (rq->q == ctrl->admin_q && (req->flags & NVME_REQ_USERCMD))
+	if (rq->q == ctrl->admin_q && (req->flags & NVME_REQ_USERCMD) &&
+	    (nvme_ctrl_state(ctrl) != NVME_CTRL_CONNECTING))
 		return false;
 
 	if (ctrl->ops->flags & NVME_F_FABRICS) {
-- 
2.25.1


             reply	other threads:[~2025-04-25 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25 12:01 Linjun Bao [this message]
2025-04-25 15:48 ` [PATCH] nvme: avoid missing db ring during reset Keith Busch
2025-04-25 16:35   ` Linjun Bao

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=fa04f3d5-56ff-62bb-0afd-ad94e961ddee@gmail.com \
    --to=meljbao@gmail.com \
    --cc=axboe@fb.com \
    --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 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.