mirror of
https://github.com/torvalds/linux.git
synced 2026-09-29 12:24:02 +02:00
nvme-rdma: refactor nvme_rdma_alloc_queue() to take a queue pointer
Callers are responsible for initializing queue->ctrl and queue->queue_size before calling nvme_rdma_alloc_queue(), which now derives ctrl and idx from the queue pointer directly. This removes redundant assignments inside the function and simplifies the interface. Signed-off-by: Surabhi Gogte <sgogte@purestorage.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
ba6e9472b4
commit
f4254b18d4
|
|
@ -566,16 +566,14 @@ static int nvme_rdma_create_queue_ib(struct nvme_rdma_queue *queue)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int nvme_rdma_alloc_queue(struct nvme_rdma_ctrl *ctrl,
|
||||
int idx, size_t queue_size)
|
||||
static int nvme_rdma_alloc_queue(struct nvme_rdma_queue *queue)
|
||||
{
|
||||
struct nvme_rdma_queue *queue;
|
||||
struct nvme_rdma_ctrl *ctrl = queue->ctrl;
|
||||
int idx = nvme_rdma_queue_idx(queue);
|
||||
struct sockaddr *src_addr = NULL;
|
||||
int ret;
|
||||
|
||||
queue = &ctrl->queues[idx];
|
||||
mutex_init(&queue->queue_lock);
|
||||
queue->ctrl = ctrl;
|
||||
if (idx && ctrl->ctrl.max_integrity_segments)
|
||||
queue->pi_support = true;
|
||||
else
|
||||
|
|
@ -587,8 +585,6 @@ static int nvme_rdma_alloc_queue(struct nvme_rdma_ctrl *ctrl,
|
|||
else
|
||||
queue->cmnd_capsule_len = sizeof(struct nvme_command);
|
||||
|
||||
queue->queue_size = queue_size;
|
||||
|
||||
queue->cm_id = rdma_create_id(&init_net, nvme_rdma_cm_handler, queue,
|
||||
RDMA_PS_TCP, IB_QPT_RC);
|
||||
if (IS_ERR(queue->cm_id)) {
|
||||
|
|
@ -736,8 +732,9 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)
|
|||
|
||||
nvmf_set_io_queues(opts, nr_io_queues, ctrl->io_queues);
|
||||
for (i = 1; i < ctrl->ctrl.queue_count; i++) {
|
||||
ret = nvme_rdma_alloc_queue(ctrl, i,
|
||||
ctrl->ctrl.sqsize + 1);
|
||||
ctrl->queues[i].ctrl = ctrl;
|
||||
ctrl->queues[i].queue_size = ctrl->ctrl.sqsize + 1;
|
||||
ret = nvme_rdma_alloc_queue(&ctrl->queues[i]);
|
||||
if (ret)
|
||||
goto out_free_queues;
|
||||
}
|
||||
|
|
@ -783,7 +780,9 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,
|
|||
bool pi_capable = false;
|
||||
int error;
|
||||
|
||||
error = nvme_rdma_alloc_queue(ctrl, 0, NVME_AQ_DEPTH);
|
||||
ctrl->queues[0].ctrl = ctrl;
|
||||
ctrl->queues[0].queue_size = NVME_AQ_DEPTH;
|
||||
error = nvme_rdma_alloc_queue(&ctrl->queues[0]);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user