Skip to contentSkip to conversation

nvme-pci: refactoring nvme_queue_rqs

PATCH In review Irvin Cote 2 participants 2 messages May 2, 2023 NVMe

lore
Share & tools
lore

Irvin Cote

author
#0 lore raw

PATCH 1/1 nvme-pci: refactoring nvme_queue_rqs

When dealing with the queue_rqs callback, the block layer guarantees that it only provides with us with requests from the same queue (cf include/linux/blk-mq.h). Therefore, we can reduce the code for nvme_queue_rqs. We retrieve the nvmeq once because it is the same for all the requests. Then the only thing the for loop does is test the requests and move them accordingly to requeue list. Finally we submit rqlist once outside the loop.

---
 drivers/nvme/host/pci.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/nvme/host/pci.c +5 -9
index 7f25c0fe3a0b..f6cbcb63fc5d 100644
@@ -934,8 +934,9 @@ static void nvme_queue_rqs(struct request **rqlist)
 	struct request *req, *next, *prev = NULL;
 	struct request *requeue_list = NULL;
 
+	struct nvme_queue *nvmeq = *rqlist->mq_hctx->driver_data;
+
 	rq_list_for_each_safe(rqlist, req, next) {
-		struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
 
 		if (!nvme_prep_rq_batch(nvmeq, req)) {
 			/* detach 'req' and add to remainder list */
@@ -946,16 +947,11 @@ static void nvme_queue_rqs(struct request **rqlist)
 				continue;
 		}
 
-		if (!next || req->mq_hctx != next->mq_hctx) {
-			/* detach rest of list, and submit */
-			req->rq_next = NULL;
-			nvme_submit_cmds(nvmeq, rqlist);
-			*rqlist = next;
-			prev = NULL;
-		} else
-			prev = req;
+		prev = req;
 	}
 
+	nvme_submit_cmds(nvmeq, rqlist);
+
 	*rqlist = requeue_list;
 }
 
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 3 lines · Irvin Cote

When dealing with the queue_rqs callback, the block layer guarantees that it only provides with us with requests from the same queue (cf include/linux/blk-mq.h).

blk-mq only guarantees the list of requests are all from the same request_queue, not necessarily the same hctx. At the nvme driver level, this means the request list is for the same namespace, but not necessarily allocated out of the same SQ.