[PATCH 1/1] nvmet-rdma: calculate the drain completion once

Max Gurtovoy mgurtovoy at nvidia.com
Wed May 25 08:00:20 PDT 2022


Keep this calculation at the local variable (nr_cqe) once instead of
adding it separately 3 times in one function.

Reviewed-by: Israel Rukshin <israelr at nvidia.com>
Signed-off-by: Max Gurtovoy <mgurtovoy at nvidia.com>
---
 drivers/nvme/target/rdma.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 2fab0b219b25..c572f9eac547 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -1263,16 +1263,15 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)
 	int nr_cqe, ret, i, factor;
 
 	/*
-	 * Reserve CQ slots for RECV + RDMA_READ/RDMA_WRITE + RDMA_SEND.
+	 * Reserve CQ slots for RECV + RDMA_READ/RDMA_WRITE + RDMA_SEND + drain.
 	 */
-	nr_cqe = queue->recv_queue_size + 2 * queue->send_queue_size;
+	nr_cqe = queue->recv_queue_size + 2 * queue->send_queue_size + 1;
 
-	queue->cq = ib_cq_pool_get(ndev->device, nr_cqe + 1,
+	queue->cq = ib_cq_pool_get(ndev->device, nr_cqe,
 				   queue->comp_vector, IB_POLL_WORKQUEUE);
 	if (IS_ERR(queue->cq)) {
 		ret = PTR_ERR(queue->cq);
-		pr_err("failed to create CQ cqe= %d ret= %d\n",
-		       nr_cqe + 1, ret);
+		pr_err("failed to create CQ cqe= %d ret= %d\n", nr_cqe, ret);
 		goto out;
 	}
 
@@ -1329,7 +1328,7 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)
 err_destroy_qp:
 	rdma_destroy_qp(queue->cm_id);
 err_destroy_cq:
-	ib_cq_pool_put(queue->cq, nr_cqe + 1);
+	ib_cq_pool_put(queue->cq, nr_cqe);
 	goto out;
 }
 
-- 
2.18.1




More information about the Linux-nvme mailing list