[PATCH v5] nvme: Skip trace complete_rq on host path error

From: Minsik Jeon

Date: Wed Mar 25 2026 - 22:09:57 EST


we were checking host_pathing_error before calling nvme_setup_cmd().
This is caused the command setup to be skipped entirely when a pathing
error occurred, making it impossible to trace the nvme command via
trace_cmd nvme_complete_rq().

As a result, when nvme_complete_rq() logged a completion with cmdid=0,
it was impossible to correlate the completion with the nvme command
request.

This patch Skip trace_nvme_complete_rq() on NVMe host path error.

Co-authored-by: Beomsoo Kim <beomsooo.kim@xxxxxxxxxxx>
Co-authored-by: Eunsoo Lee <euns212.lee@xxxxxxxxxxx>
Co-authored-by: Steven Seungcheol Lee <sc108.lee@xxxxxxxxxxx>
Signed-off-by: Minsik Jeon <hmi.jeon@xxxxxxxxxxx>
---
drivers/nvme/host/core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 766e9cc4ffca..df5a47b8560d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -458,7 +458,14 @@ void nvme_complete_rq(struct request *req)
{
struct nvme_ctrl *ctrl = nvme_req(req)->ctrl;

- trace_nvme_complete_rq(req);
+ /*
+ * The idea for these trace events was to match up commands
+ * dispatched to hardware with the hardware's posted response.
+ * So skip tracing for undispatched commands.
+ */
+ if (nvme_req(req)->status != NVME_SC_HOST_PATH_ERROR)
+ trace_nvme_complete_rq(req);
+
nvme_cleanup_cmd(req);

/*
--
2.52.0