[PATCH] nvme: set passthrough command gendisk

Keith Busch kbusch at kernel.org
Wed Oct 14 16:38:45 EDT 2020


The nvme event traces for IO commands are reporting the wrong QID
because we never set the request's gendisk. Set this parameter if the
passthrough command is being sent through an IO queue.

Signed-off-by: Keith Busch <kbusch at kernel.org>
---
 drivers/nvme/host/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 95ef4943d8bd..ab5921e824d5 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -894,9 +894,14 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
 		unsigned timeout, int qid, int at_head,
 		blk_mq_req_flags_t flags, bool poll)
 {
+	struct nvme_ns *ns = q->queuedata;
+	struct gendisk *disk = NULL;
 	struct request *req;
 	int ret;
 
+	if (ns)
+		disk = ns->disk;
+
 	req = nvme_alloc_request(q, cmd, flags, qid);
 	if (IS_ERR(req))
 		return PTR_ERR(req);
@@ -910,9 +915,9 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
 	}
 
 	if (poll)
-		nvme_execute_rq_polled(req->q, NULL, req, at_head);
+		nvme_execute_rq_polled(req->q, disk, req, at_head);
 	else
-		blk_execute_rq(req->q, NULL, req, at_head);
+		blk_execute_rq(req->q, disk, req, at_head);
 	if (result)
 		*result = nvme_req(req)->result;
 	if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
-- 
2.24.1




More information about the Linux-nvme mailing list