Commit 1864ea46 authored by Christoph Hellwig's avatar Christoph Hellwig

nvme-fc: store the generic nvme_ctrl in set->driver_data

Point the private data to the generic controller structure in preparation
of using the common tagset init/exit code and use the chance the cleanup
the init_hctx methods a bit.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarJames Smart <jsmart2021@gmail.com>
parent 18ecd975
...@@ -1829,7 +1829,7 @@ nvme_fc_exit_request(struct blk_mq_tag_set *set, struct request *rq, ...@@ -1829,7 +1829,7 @@ nvme_fc_exit_request(struct blk_mq_tag_set *set, struct request *rq,
{ {
struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq); struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq);
return __nvme_fc_exit_request(set->driver_data, op); return __nvme_fc_exit_request(to_fc_ctrl(set->driver_data), op);
} }
static int static int
...@@ -2135,7 +2135,7 @@ static int ...@@ -2135,7 +2135,7 @@ static int
nvme_fc_init_request(struct blk_mq_tag_set *set, struct request *rq, nvme_fc_init_request(struct blk_mq_tag_set *set, struct request *rq,
unsigned int hctx_idx, unsigned int numa_node) unsigned int hctx_idx, unsigned int numa_node)
{ {
struct nvme_fc_ctrl *ctrl = set->driver_data; struct nvme_fc_ctrl *ctrl = to_fc_ctrl(set->driver_data);
struct nvme_fcp_op_w_sgl *op = blk_mq_rq_to_pdu(rq); struct nvme_fcp_op_w_sgl *op = blk_mq_rq_to_pdu(rq);
int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0; int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0;
struct nvme_fc_queue *queue = &ctrl->queues[queue_idx]; struct nvme_fc_queue *queue = &ctrl->queues[queue_idx];
...@@ -2206,36 +2206,28 @@ nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) ...@@ -2206,36 +2206,28 @@ nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl)
} }
} }
static inline void static inline int
__nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, struct nvme_fc_ctrl *ctrl, __nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, unsigned int qidx)
unsigned int qidx)
{ {
struct nvme_fc_ctrl *ctrl = to_fc_ctrl(data);
struct nvme_fc_queue *queue = &ctrl->queues[qidx]; struct nvme_fc_queue *queue = &ctrl->queues[qidx];
hctx->driver_data = queue; hctx->driver_data = queue;
queue->hctx = hctx; queue->hctx = hctx;
return 0;
} }
static int static int
nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, nvme_fc_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, unsigned int hctx_idx)
unsigned int hctx_idx)
{ {
struct nvme_fc_ctrl *ctrl = data; return __nvme_fc_init_hctx(hctx, data, hctx_idx + 1);
__nvme_fc_init_hctx(hctx, ctrl, hctx_idx + 1);
return 0;
} }
static int static int
nvme_fc_init_admin_hctx(struct blk_mq_hw_ctx *hctx, void *data, nvme_fc_init_admin_hctx(struct blk_mq_hw_ctx *hctx, void *data,
unsigned int hctx_idx) unsigned int hctx_idx)
{ {
struct nvme_fc_ctrl *ctrl = data; return __nvme_fc_init_hctx(hctx, data, hctx_idx);
__nvme_fc_init_hctx(hctx, ctrl, hctx_idx);
return 0;
} }
static void static void
...@@ -2862,7 +2854,7 @@ nvme_fc_complete_rq(struct request *rq) ...@@ -2862,7 +2854,7 @@ nvme_fc_complete_rq(struct request *rq)
static void nvme_fc_map_queues(struct blk_mq_tag_set *set) static void nvme_fc_map_queues(struct blk_mq_tag_set *set)
{ {
struct nvme_fc_ctrl *ctrl = set->driver_data; struct nvme_fc_ctrl *ctrl = to_fc_ctrl(set->driver_data);
int i; int i;
for (i = 0; i < set->nr_maps; i++) { for (i = 0; i < set->nr_maps; i++) {
...@@ -2923,7 +2915,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) ...@@ -2923,7 +2915,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
ctrl->tag_set.cmd_size = ctrl->tag_set.cmd_size =
struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv, struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
ctrl->lport->ops->fcprqst_priv_sz); ctrl->lport->ops->fcprqst_priv_sz);
ctrl->tag_set.driver_data = ctrl; ctrl->tag_set.driver_data = &ctrl->ctrl;
ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count - 1; ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count - 1;
ctrl->tag_set.timeout = NVME_IO_TIMEOUT; ctrl->tag_set.timeout = NVME_IO_TIMEOUT;
...@@ -3546,7 +3538,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, ...@@ -3546,7 +3538,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
ctrl->admin_tag_set.cmd_size = ctrl->admin_tag_set.cmd_size =
struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv, struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
ctrl->lport->ops->fcprqst_priv_sz); ctrl->lport->ops->fcprqst_priv_sz);
ctrl->admin_tag_set.driver_data = ctrl; ctrl->admin_tag_set.driver_data = &ctrl->ctrl;
ctrl->admin_tag_set.nr_hw_queues = 1; ctrl->admin_tag_set.nr_hw_queues = 1;
ctrl->admin_tag_set.timeout = NVME_ADMIN_TIMEOUT; ctrl->admin_tag_set.timeout = NVME_ADMIN_TIMEOUT;
ctrl->admin_tag_set.flags = BLK_MQ_F_NO_SCHED; ctrl->admin_tag_set.flags = BLK_MQ_F_NO_SCHED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment