提交 ca6e95bb 编写于 作者: S Sagi Grimberg 提交者: Christoph Hellwig

nvme-rdma: make nvme_rdma_[create|destroy]_queue_ib symmetrical

We put the reference on the device in the destroy routine
so we should lookup and take the reference in the create
routine.
Signed-off-by: NSagi Grimberg <sagi@grimberg.me>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
上级 c8295d11
...@@ -480,17 +480,21 @@ static void nvme_rdma_destroy_queue_ib(struct nvme_rdma_queue *queue) ...@@ -480,17 +480,21 @@ static void nvme_rdma_destroy_queue_ib(struct nvme_rdma_queue *queue)
nvme_rdma_dev_put(dev); nvme_rdma_dev_put(dev);
} }
static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue, static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue)
struct nvme_rdma_device *dev)
{ {
struct ib_device *ibdev = dev->dev; struct ib_device *ibdev;
const int send_wr_factor = 3; /* MR, SEND, INV */ const int send_wr_factor = 3; /* MR, SEND, INV */
const int cq_factor = send_wr_factor + 1; /* + RECV */ const int cq_factor = send_wr_factor + 1; /* + RECV */
int comp_vector, idx = nvme_rdma_queue_idx(queue); int comp_vector, idx = nvme_rdma_queue_idx(queue);
int ret; int ret;
queue->device = dev; queue->device = nvme_rdma_find_get_device(queue->cm_id);
if (!queue->device) {
dev_err(queue->cm_id->device->dev.parent,
"no client data found!\n");
return -ECONNREFUSED;
}
ibdev = queue->device->dev;
/* /*
* The admin queue is barely used once the controller is live, so don't * The admin queue is barely used once the controller is live, so don't
...@@ -503,12 +507,12 @@ static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue, ...@@ -503,12 +507,12 @@ static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue,
/* +1 for ib_stop_cq */ /* +1 for ib_stop_cq */
queue->ib_cq = ib_alloc_cq(dev->dev, queue, queue->ib_cq = ib_alloc_cq(ibdev, queue,
cq_factor * queue->queue_size + 1, comp_vector, cq_factor * queue->queue_size + 1,
IB_POLL_SOFTIRQ); comp_vector, IB_POLL_SOFTIRQ);
if (IS_ERR(queue->ib_cq)) { if (IS_ERR(queue->ib_cq)) {
ret = PTR_ERR(queue->ib_cq); ret = PTR_ERR(queue->ib_cq);
goto out; goto out_put_dev;
} }
ret = nvme_rdma_create_qp(queue, send_wr_factor); ret = nvme_rdma_create_qp(queue, send_wr_factor);
...@@ -529,7 +533,8 @@ static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue, ...@@ -529,7 +533,8 @@ static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue,
ib_destroy_qp(queue->qp); ib_destroy_qp(queue->qp);
out_destroy_ib_cq: out_destroy_ib_cq:
ib_free_cq(queue->ib_cq); ib_free_cq(queue->ib_cq);
out: out_put_dev:
nvme_rdma_dev_put(queue->device);
return ret; return ret;
} }
...@@ -1275,21 +1280,11 @@ static int nvme_rdma_conn_rejected(struct nvme_rdma_queue *queue, ...@@ -1275,21 +1280,11 @@ static int nvme_rdma_conn_rejected(struct nvme_rdma_queue *queue,
static int nvme_rdma_addr_resolved(struct nvme_rdma_queue *queue) static int nvme_rdma_addr_resolved(struct nvme_rdma_queue *queue)
{ {
struct nvme_rdma_device *dev;
int ret; int ret;
dev = nvme_rdma_find_get_device(queue->cm_id); ret = nvme_rdma_create_queue_ib(queue);
if (!dev) { if (ret)
dev_err(queue->cm_id->device->dev.parent, return ret;
"no client data found!\n");
return -ECONNREFUSED;
}
ret = nvme_rdma_create_queue_ib(queue, dev);
if (ret) {
nvme_rdma_dev_put(dev);
goto out;
}
ret = rdma_resolve_route(queue->cm_id, NVME_RDMA_CONNECT_TIMEOUT_MS); ret = rdma_resolve_route(queue->cm_id, NVME_RDMA_CONNECT_TIMEOUT_MS);
if (ret) { if (ret) {
...@@ -1303,7 +1298,6 @@ static int nvme_rdma_addr_resolved(struct nvme_rdma_queue *queue) ...@@ -1303,7 +1298,6 @@ static int nvme_rdma_addr_resolved(struct nvme_rdma_queue *queue)
out_destroy_queue: out_destroy_queue:
nvme_rdma_destroy_queue_ib(queue); nvme_rdma_destroy_queue_ib(queue);
out:
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册