[PATCH] nvme-pci: check for valid request when polling for completions
Hannes Reinecke
hare at kernel.org
Mon Sep 2 06:07:28 PDT 2024
When polling for completions from the timeout handler we traverse
over _all_ cqes, and the fetching the request via blk_mq_tag_to_rq().
Unfortunately that function will always return a request, even if
that request is already completed.
So we need to check if the command is still in flight before
attempting to complete it.
Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
drivers/nvme/host/pci.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 6cd9395ba9ec..fc4c616516d6 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1037,6 +1037,13 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
return;
}
+ if (blk_mq_rq_state(req) != MQ_RQ_IN_FLIGHT) {
+ dev_warn(nvmeq->dev->ctrl.device,
+ "stale completion id %d on queue %d\n",
+ command_id, le16_to_cpu(cqe->sq_id));
+ return;
+ }
+
trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
if (!nvme_try_complete_req(req, cqe->status, cqe->result) &&
!blk_mq_add_to_batch(req, iob, nvme_req(req)->status,
--
2.35.3
More information about the Linux-nvme
mailing list