consolidate tagset / misc request_queue allocation
Subsystems (3)
Christoph Hellwig
maintainerHi all,
this series consolidates the allocation and freeing of the tagsets and misc (non-I/O) requests queues over the various fabrics drivers.
Eventually PCIe and the apple controller driver should use these helpers as well, but that will require some additional cleanups of the request_queue lifetime first.
Diffstat:
host/core.c | 100 +++++++++++++++++++++++++++++++++++++++++ host/fc.c | 121 +++++++++++-------------------------------------- host/nvme.h | 16 +++--- host/rdma.c | 141 +++++++++++++++------------------------------------------- host/tcp.c | 118 +++++++++--------------------------------------- target/loop.c | 91 +++++++++---------------------------- 6 files changed, 220 insertions(+), 367 deletions(-)
Christoph Hellwig
maintainerPATCH 1/13 nvme: add common helpers to allocate and free tagsets
Add common helpers to allocate and tear down the admin and I/O tag sets, including the special queues allocated with them.
--- drivers/nvme/host/core.c | 100 +++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 8 ++++ 2 files changed, 108 insertions(+)
drivers/nvme/host/core.c +100 -0
@@ -4800,6 +4800,106 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, }EXPORT_SYMBOL_GPL (nvme_complete_async_event); +int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size) +{ +int ret; + +memset (set,0 ,sizeof (*set)); + set->ops = ops; + set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ; +if (ctrl->ops->flags &NVME_F_FABRICS ) + set->reserved_tags =NVMF_RESERVED_TAGS ; + set->numa_node = ctrl->numa_node; + set->flags = flags; + set->cmd_size = cmd_size; + set->driver_data = ctrl; + set->nr_hw_queues =1 ; + set->timeout =NVME_ADMIN_TIMEOUT ; + ret =blk_mq_alloc_tag_set (set); +if (ret) +return ret; + + ctrl->admin_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->admin_q)) { + ret =PTR_ERR (ctrl->admin_q); + goto out_free_tagset; + } + +if (ctrl->ops->flags &NVME_F_FABRICS ) { + ctrl->fabrics_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->fabrics_q)) { + ret =PTR_ERR (ctrl->fabrics_q); + goto out_cleanup_admin_q; + } + } + + ctrl->admin_tagset = set; +return 0 ; + +out_cleanup_admin_q: +blk_mq_destroy_queue (ctrl->fabrics_q); +out_free_tagset: +blk_mq_free_tag_set (ctrl->admin_tagset); +return ret; +} +EXPORT_SYMBOL_GPL (nvme_alloc_admin_tag_set); + +void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl) +{ +blk_mq_destroy_queue (ctrl->admin_q); +if (ctrl->ops->flags &NVME_F_FABRICS ) +blk_mq_destroy_queue (ctrl->fabrics_q); +blk_mq_free_tag_set (ctrl->admin_tagset); +} +EXPORT_SYMBOL_GPL (nvme_remove_admin_tag_set); + +int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size) +{ +int ret; + +memset (set,0 ,sizeof (*set)); + set->ops = ops; + set->queue_depth = ctrl->sqsize +1 ; + set->reserved_tags =NVMF_RESERVED_TAGS ; + set->numa_node = ctrl->numa_node; + set->flags = flags; + set->cmd_size = cmd_size, + set->driver_data = ctrl; + set->nr_hw_queues = ctrl->queue_count -1 ; + set->timeout =NVME_IO_TIMEOUT ; +if (ops->map_queues) + set->nr_maps = ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ; + ret =blk_mq_alloc_tag_set (set); +if (ret) +return ret; + + ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set; + } + + ctrl->tagset = set; +return 0 ; + +out_free_tag_set: +blk_mq_free_tag_set (set); +return ret; +} +EXPORT_SYMBOL_GPL (nvme_alloc_io_tag_set); + +void nvme_remove_io_tag_set (struct nvme_ctrl *ctrl) +{ +if (ctrl->ops->flags &NVME_F_FABRICS ) +blk_mq_destroy_queue (ctrl->connect_q); +blk_mq_free_tag_set (ctrl->tagset); +} +EXPORT_SYMBOL_GPL (nvme_remove_io_tag_set); +void nvme_stop_ctrl (struct nvme_ctrl *ctrl) {nvme_mpath_stop (ctrl);
drivers/nvme/host/nvme.h +8 -0
@@ -722,6 +722,14 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);void nvme_start_ctrl (struct nvme_ctrl *ctrl);void nvme_stop_ctrl (struct nvme_ctrl *ctrl);int nvme_init_ctrl_finish (struct nvme_ctrl *ctrl); +int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size); +void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl); +int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size); +void nvme_remove_io_tag_set (struct nvme_ctrl *ctrl);void nvme_remove_namespaces (struct nvme_ctrl *ctrl);
Signature · 1 line
2.30.2
Re: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 4 lines · Christoph Hellwig
Add common helpers to allocate and tear down the admin and I/O tag sets, including the special queues allocated with them.
Signed-off-by Christoph Hellwig <[email protected]>
Thanks for doing this, I remember sending similar series, didn't get a chance to peruse that to completion.
Looks good.
Re: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
In reply to Christoph HellwigQuoted 89 lines · Christoph Hellwig
Add common helpers to allocate and tear down the admin and I/O tag sets, including the special queues allocated with them.
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/core.c | 100 +++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 8 ++++ 2 files changed, 108 insertions(+)drivers/nvme/host/core.c +72
-0@@ -4800,6 +4800,106 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, }EXPORT_SYMBOL_GPL (nvme_complete_async_event); +int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size) +{ +int ret; + +memset (set,0 ,sizeof (*set)); + set->ops = ops; + set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ; +if (ctrl->ops->flags &NVME_F_FABRICS ) + set->reserved_tags =NVMF_RESERVED_TAGS ; + set->numa_node = ctrl->numa_node; + set->flags = flags; + set->cmd_size = cmd_size; + set->driver_data = ctrl; + set->nr_hw_queues =1 ; + set->timeout =NVME_ADMIN_TIMEOUT ; + ret =blk_mq_alloc_tag_set (set); +if (ret) +return ret; + + ctrl->admin_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->admin_q)) { + ret =PTR_ERR (ctrl->admin_q); + goto out_free_tagset; + } + +if (ctrl->ops->flags &NVME_F_FABRICS ) { + ctrl->fabrics_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->fabrics_q)) { + ret =PTR_ERR (ctrl->fabrics_q); + goto out_cleanup_admin_q; + } + } + + ctrl->admin_tagset = set; +return 0 ; + +out_cleanup_admin_q: +blk_mq_destroy_queue (ctrl->fabrics_q); +out_free_tagset: +blk_mq_free_tag_set (ctrl->admin_tagset); +return ret; +} +EXPORT_SYMBOL_GPL (nvme_alloc_admin_tag_set); + +void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl) +{ +blk_mq_destroy_queue (ctrl->admin_q); +if (ctrl->ops->flags &NVME_F_FABRICS ) +blk_mq_destroy_queue (ctrl->fabrics_q); +blk_mq_free_tag_set (ctrl->admin_tagset); +} +EXPORT_SYMBOL_GPL (nvme_remove_admin_tag_set); + +int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size) +{ +int ret; + +memset (set,0 ,sizeof (*set)); + set->ops = ops; + set->queue_depth = ctrl->sqsize +1 ; + set->reserved_tags =NVMF_RESERVED_TAGS ; + set->numa_node = ctrl->numa_node; + set->flags = flags; + set->cmd_size = cmd_size, + set->driver_data = ctrl; + set->nr_hw_queues = ctrl->queue_count -1 ; + set->timeout =NVME_IO_TIMEOUT ; +if (ops->map_queues)
drivers/nvme/host/core.c void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, · line 4884
Quoted 10 lines
drivers/nvme/host/core.c +10
-0+ set->nr_maps = ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ; + ret =blk_mq_alloc_tag_set (set); +if (ret) +return ret; + + ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set; + }
Maybe we should move the connect_q related code to nvme_alloc_admin_tag_set. Thus we don't need to set NVMF_RESERVED_TAGS for tagset,
if there are large amount of ns queues, it will save resources. At the same time, it will simplify tagset-based implementation. According to the behavior logic, connect_q is a management resource. However, connect_q use the I/O tagset.
As a result, it is difficult to process some logic based on tagset.
Quoted 41 lines
drivers/nvme/host/core.c +18
-0+ + ctrl->tagset = set; +return 0 ; + +out_free_tag_set: +blk_mq_free_tag_set (set); +return ret; +} +EXPORT_SYMBOL_GPL (nvme_alloc_io_tag_set); + +void nvme_remove_io_tag_set (struct nvme_ctrl *ctrl) +{ +if (ctrl->ops->flags &NVME_F_FABRICS ) +blk_mq_destroy_queue (ctrl->connect_q); +blk_mq_free_tag_set (ctrl->tagset); +} +EXPORT_SYMBOL_GPL (nvme_remove_io_tag_set); +void nvme_stop_ctrl (struct nvme_ctrl *ctrl) {nvme_mpath_stop (ctrl);drivers/nvme/host/nvme.h +8
-0@@ -722,6 +722,14 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);void nvme_start_ctrl (struct nvme_ctrl *ctrl);void nvme_stop_ctrl (struct nvme_ctrl *ctrl);int nvme_init_ctrl_finish (struct nvme_ctrl *ctrl); +int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size); +void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl); +int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size); +void nvme_remove_io_tag_set (struct nvme_ctrl *ctrl);void nvme_remove_namespaces (struct nvme_ctrl *ctrl);
Christoph Hellwig
maintainerRe: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 4 lines · Chao Leng
Quoted 4 lines
drivers/nvme/host/core.c +4
-0+ ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set;
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }Maybe we should move the
connect_qrelated code tonvme_alloc_admin_tag_set. Thus we don't need to setNVMF_RESERVED_TAGSfor tagset,
if there are large amount of ns queues, it will save resources. At the same time, it will simplify tagset-based implementation. According to the behavior logic,connect_qis a management resource. However,connect_quse the I/O tagset.
As a result, it is difficult to process some logic based on tagset.
The fabrics connect command needs to be sent on each of the I/O queues in addition to the admin queue, which means the admin tag_set can't be used.
Re: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 14 lines · Christoph Hellwig
Quoted 4 lines · Chao Leng
Quoted 4 lines
drivers/nvme/host/core.c +4
-0+ ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set;Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }Maybe we should move the
connect_qrelated code tonvme_alloc_admin_tag_set. Thus we don't need to setNVMF_RESERVED_TAGSfor tagset,
if there are large amount of ns queues, it will save resources. At the same time, it will simplify tagset-based implementation. According to the behavior logic,connect_qis a management resource. However,connect_quse the I/O tagset.
As a result, it is difficult to process some logic based on tagset.
Quoted 3 lines
The fabrics connect command needs to be sent on each of the I/O queues in addition to the admin queue, which means the admin
tag_setcan't be used.
We can do some special processing in nvme_setup_cmd for connect command to treat queue mapping.
Do you think that's okay?
Quoted 4 lines
.
Christoph Hellwig
maintainerRe: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 3 lines · Chao Leng
We can do some special processing in
nvme_setup_cmdfor connect command to treat queue mapping.
Do you think that's okay?
nvme_setup_cmd does not help, as anything we could do there we could in the code that submits the command. The point is that it needs to be sent out on the hctx for that particular I/O queue.
Sagi Grimberg
maintainerRe: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
In reply to Christoph HellwigQuoted 84 lines · Christoph Hellwig
Add common helpers to allocate and tear down the admin and I/O tag sets, including the special queues allocated with them.
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/core.c | 100 +++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 8 ++++ 2 files changed, 108 insertions(+)drivers/nvme/host/core.c +67
-0@@ -4800,6 +4800,106 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, }EXPORT_SYMBOL_GPL (nvme_complete_async_event); +int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size) +{ +int ret; + +memset (set,0 ,sizeof (*set)); + set->ops = ops; + set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ; +if (ctrl->ops->flags &NVME_F_FABRICS ) + set->reserved_tags =NVMF_RESERVED_TAGS ; + set->numa_node = ctrl->numa_node; + set->flags = flags; + set->cmd_size = cmd_size; + set->driver_data = ctrl; + set->nr_hw_queues =1 ; + set->timeout =NVME_ADMIN_TIMEOUT ; + ret =blk_mq_alloc_tag_set (set); +if (ret) +return ret; + + ctrl->admin_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->admin_q)) { + ret =PTR_ERR (ctrl->admin_q); + goto out_free_tagset; + } + +if (ctrl->ops->flags &NVME_F_FABRICS ) { + ctrl->fabrics_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->fabrics_q)) { + ret =PTR_ERR (ctrl->fabrics_q); + goto out_cleanup_admin_q; + } + } + + ctrl->admin_tagset = set; +return 0 ; + +out_cleanup_admin_q: +blk_mq_destroy_queue (ctrl->fabrics_q); +out_free_tagset: +blk_mq_free_tag_set (ctrl->admin_tagset); +return ret; +} +EXPORT_SYMBOL_GPL (nvme_alloc_admin_tag_set); + +void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl) +{ +blk_mq_destroy_queue (ctrl->admin_q); +if (ctrl->ops->flags &NVME_F_FABRICS ) +blk_mq_destroy_queue (ctrl->fabrics_q); +blk_mq_free_tag_set (ctrl->admin_tagset); +} +EXPORT_SYMBOL_GPL (nvme_remove_admin_tag_set); + +int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, +const struct blk_mq_ops *ops,unsigned int flags, +unsigned int cmd_size) +{ +int ret; + +memset (set,0 ,sizeof (*set)); + set->ops = ops; + set->queue_depth = ctrl->sqsize +1 ; + set->reserved_tags =NVMF_RESERVED_TAGS ; + set->numa_node = ctrl->numa_node; + set->flags = flags;
drivers/nvme/host/core.c void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, · line 4879
Quoted 10 lines
drivers/nvme/host/core.c +10
-0+ set->cmd_size = cmd_size, + set->driver_data = ctrl; + set->nr_hw_queues = ctrl->queue_count -1 ; + set->timeout =NVME_IO_TIMEOUT ; +if (ops->map_queues) + set->nr_maps = ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ; + ret =blk_mq_alloc_tag_set (set); +if (ret) +return ret; +
if (ctrl->ops->flags & NVME_F_FABRICS) {
drivers/nvme/host/core.c void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, · line 4884
Quoted 5 lines
drivers/nvme/host/core.c +5
-0+ ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set; + }
}
Quoted 9 lines
drivers/nvme/host/core.c +9
-0+ + ctrl->tagset = set; +return 0 ; + +out_free_tag_set: +blk_mq_free_tag_set (set); +return ret; +} +EXPORT_SYMBOL_GPL (nvme_alloc_io_tag_set);
Christoph Hellwig
maintainerRe: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 8 lines · Sagi Grimberg
Review
Quoted 6 lines
(quoted diff) +6
-0+ if (ops->map_queues) + set->nr_maps = ctrl->opts->nr_poll_queues ? HCTX_MAX_TYPES : 2; + ret = blk_mq_alloc_tag_set(set); + if (ret) + return ret; +if (
ctrl->ops->flags&NVME_F_FABRICS) {
Incremental fixup:
drivers/nvme/host/core.c +6 -4
@@ -4877,10 +4877,12 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,if (ret)return ret; - ctrl->connect_q =blk_mq_init_queue (set); -if (IS_ERR (ctrl->connect_q)) { - ret =PTR_ERR (ctrl->connect_q); - goto out_free_tag_set; +if (ctrl->ops->flags &NVME_F_FABRICS ) { + ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set; + } } ctrl->tagset = set;
Re: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 21 lines · Christoph Hellwig
Quoted 8 lines · Sagi Grimberg
Review
Quoted 6 lines
(quoted diff) +6
-0+ if (ops->map_queues) + set->nr_maps = ctrl->opts->nr_poll_queues ? HCTX_MAX_TYPES : 2; + ret = blk_mq_alloc_tag_set(set); + if (ret) + return ret; +if (
ctrl->ops->flags&NVME_F_FABRICS) {Incremental fixup:
drivers/nvme/host/core.c +0
-1@@ -4877,10 +4877,12 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,if (ret)return ret; - ctrl->connect_q =blk_mq_init_queue (set);
drivers/nvme/host/core.c int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, · line 4886
Quoted 10 lines
drivers/nvme/host/core.c +6
-3-if (IS_ERR (ctrl->connect_q)) { - ret =PTR_ERR (ctrl->connect_q); - goto out_free_tag_set; +if (ctrl->ops->flags &NVME_F_FABRICS ) { + ctrl->connect_q =blk_mq_init_queue (set); +if (IS_ERR (ctrl->connect_q)) { + ret =PTR_ERR (ctrl->connect_q); + goto out_free_tag_set; + } }
Maybe we should not add the checking of NVME_F_FABRICS.
+ if (ctrl->ops->flags & NVME_F_FABRICS) {
+ ctrl->fabrics_q = blk_mq_init_queue(set);
+ if (IS_ERR(ctrl->fabrics_q)) {
+ ret = PTR_ERR(ctrl->fabrics_q);
+ goto out_cleanup_admin_q;
+ }
+ }nvme_alloc_admin_tag_set should not check NVME_F_FABRICS either. The new helpers is just used for fabrics.
Maybe adding fabric to the function name would make it clearer. Like this: nvme_alloc_fabric_admin_tag_set.
Thus can avoid confusion with nvme_alloc_admin_tags.
Quoted 5 lines
drivers/nvme/host/core.c +0
-0ctrl->tagset = set;.
Christoph Hellwig
maintainerRe: [PATCH 01/13] nvme: add common helpers to allocate and free tagsets
Quoted 10 lines · Chao Leng
Maybe we should not add the checking of
NVME_F_FABRICS.(quoted diff) +7
-0+ if (ctrl->ops->flags & NVME_F_FABRICS) { + ctrl->fabrics_q = blk_mq_init_queue(set); + if (IS_ERR(ctrl->fabrics_q)) { + ret = PTR_ERR(ctrl->fabrics_q); + goto out_cleanup_admin_q; + } + }
nvme_alloc_admin_tag_setshould not checkNVME_F_FABRICSeither. The new helpers is just used for fabrics.
Right now. As mentioned in the cover letter I plan to use it for PCIe nvme-apple as well. But that will need more work, including block layer work for request_queue refcounting first.
Christoph Hellwig
maintainerPATCH 2/13 nvme-tcp: remove the unused queue_size member in nvme_tcp_queue
In reply to Christoph Hellwig->nvme_tcp_queue is not used anywhere, so remove it.
--- drivers/nvme/host/tcp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/nvme/host/tcp.c +3 -6
@@ -134,7 +134,6 @@ struct nvme_tcp_queue {/* send state */ struct nvme_tcp_request *request; -int queue_size;u32 maxh2cdata;size_t cmnd_capsule_len;struct nvme_tcp_ctrl *ctrl;
@@ -1479,8 +1478,7 @@ static void nvme_tcp_set_queue_io_cpu(struct nvme_tcp_queue *queue) queue->io_cpu =cpumask_next_wrap (n -1 , cpu_online_mask,-1 , false); } -static int nvme_tcp_alloc_queue (struct nvme_ctrl *nctrl, -int qid,size_t queue_size) +static int nvme_tcp_alloc_queue (struct nvme_ctrl *nctrl,int qid) {struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (nctrl);struct nvme_tcp_queue *queue = &ctrl->queues[qid];
@@ -1492,7 +1490,6 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl,INIT_LIST_HEAD (&queue->send_list);mutex_init (&queue->send_mutex);INIT_WORK (&queue->io_work, nvme_tcp_io_work); - queue->queue_size = queue_size;if (qid >0 ) queue->cmnd_capsule_len = nctrl->ioccsz *16 ;
@@ -1785,7 +1782,7 @@ static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl) {int ret; - ret =nvme_tcp_alloc_queue (ctrl,0 ,NVME_AQ_DEPTH ); + ret =nvme_tcp_alloc_queue (ctrl,0 );if (ret)return ret;
@@ -1805,7 +1802,7 @@ static int __nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl)int i, ret;for (i =1 ; i < ctrl->queue_count; i++) { - ret =nvme_tcp_alloc_queue (ctrl, i, ctrl->sqsize +1 ); + ret =nvme_tcp_alloc_queue (ctrl, i);if (ret) goto out_free_queues; }
Signature · 1 line
2.30.2
Re: [PATCH 02/13] nvme-tcp: remove the unused queue_size member in nvme_tcp_queue
Quoted 4 lines · Christoph Hellwig
->nvme_tcp_queue is not used anywhere, so remove it.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 02/13] nvme-tcp: remove the unused queue_size member in nvme_tcp_queue
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 3/13 nvme-tcp: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigPoint the private data to the generic controller structure in preparation of using the common tagset init/exit code.
--- drivers/nvme/host/tcp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/tcp.c +6 -6
@@ -465,7 +465,7 @@ static int nvme_tcp_init_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx, unsigned int numa_node) { - struct nvme_tcp_ctrl *ctrl = set->driver_data; + struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(set->driver_data);struct nvme_tcp_request *req =blk_mq_rq_to_pdu (rq);struct nvme_tcp_cmd_pdu *pdu;int queue_idx = (set == &ctrl->tag_set) ? hctx_idx +1 :0 ;
@@ -489,7 +489,7 @@ static int nvme_tcp_init_request(struct blk_mq_tag_set *set,static int nvme_tcp_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_tcp_ctrl *ctrl = data; +struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (data);struct nvme_tcp_queue *queue = &ctrl->queues[hctx_idx +1 ]; hctx->driver_data = queue;
@@ -499,7 +499,7 @@ static int nvme_tcp_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,static int nvme_tcp_init_admin_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_tcp_ctrl *ctrl = data; +struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (data);struct nvme_tcp_queue *queue = &ctrl->queues[0 ]; hctx->driver_data = queue;
@@ -1700,7 +1700,7 @@ static int nvme_tcp_alloc_admin_tag_set(struct nvme_ctrl *nctrl) set->numa_node = nctrl->numa_node; set->flags =BLK_MQ_F_BLOCKING ; set->cmd_size =sizeof (struct nvme_tcp_request ); - set->driver_data = ctrl; + set->driver_data = &ctrl->ctrl; set->nr_hw_queues =1 ; set->timeout =NVME_ADMIN_TIMEOUT ; ret =blk_mq_alloc_tag_set (set);
@@ -1722,7 +1722,7 @@ static int nvme_tcp_alloc_tag_set(struct nvme_ctrl *nctrl) set->numa_node = nctrl->numa_node; set->flags =BLK_MQ_F_SHOULD_MERGE |BLK_MQ_F_BLOCKING ; set->cmd_size =sizeof (struct nvme_tcp_request ); - set->driver_data = ctrl; + set->driver_data = &ctrl->ctrl; set->nr_hw_queues = nctrl->queue_count -1 ; set->timeout =NVME_IO_TIMEOUT ; set->nr_maps = nctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ;
@@ -2486,7 +2486,7 @@ static blk_status_t nvme_tcp_queue_rq(struct blk_mq_hw_ctx *hctx,static void nvme_tcp_map_queues (struct blk_mq_tag_set *set) { -struct nvme_tcp_ctrl *ctrl = set->driver_data; +struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (set->driver_data);struct nvmf_ctrl_options *opts = ctrl->ctrl.opts;if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ ]) {
Signature · 1 line
2.30.2
Re: [PATCH 03/13] nvme-tcp: store the generic nvme_ctrl in set->driver_data
Quoted 4 lines · Christoph Hellwig
Point the private data to the generic controller structure in preparation of using the common tagset init/exit code.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 03/13] nvme-tcp: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 4/13 nvme-tcp: use the tagset alloc/free helpers
In reply to Christoph HellwigUse the common helpers to allocate and free the tagsets. To make this work the generic nvme_ctrl now needs to be stored in the hctx private data instead of the nvme_tcp_ctrl.
--- drivers/nvme/host/tcp.c | 101 +++++++--------------------------------- 1 file changed, 16 insertions(+), 85 deletions(-)
drivers/nvme/host/tcp.c +16 -85
@@ -1687,51 +1687,6 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx)return ret; } -static int nvme_tcp_alloc_admin_tag_set (struct nvme_ctrl *nctrl) -{ -struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (nctrl); -struct blk_mq_tag_set *set = &ctrl->admin_tag_set; -int ret; - -memset (set,0 ,sizeof (*set)); - set->ops = &nvme_tcp_admin_mq_ops; - set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ; - set->reserved_tags =NVMF_RESERVED_TAGS ; - set->numa_node = nctrl->numa_node; - set->flags =BLK_MQ_F_BLOCKING ; - set->cmd_size =sizeof (struct nvme_tcp_request ); - set->driver_data = &ctrl->ctrl; - set->nr_hw_queues =1 ; - set->timeout =NVME_ADMIN_TIMEOUT ; - ret =blk_mq_alloc_tag_set (set); -if (!ret) - nctrl->admin_tagset = set; -return ret; -} - -static int nvme_tcp_alloc_tag_set (struct nvme_ctrl *nctrl) -{ -struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (nctrl); -struct blk_mq_tag_set *set = &ctrl->tag_set; -int ret; - -memset (set,0 ,sizeof (*set)); - set->ops = &nvme_tcp_mq_ops; - set->queue_depth = nctrl->sqsize +1 ; - set->reserved_tags =NVMF_RESERVED_TAGS ; - set->numa_node = nctrl->numa_node; - set->flags =BLK_MQ_F_SHOULD_MERGE |BLK_MQ_F_BLOCKING ; - set->cmd_size =sizeof (struct nvme_tcp_request ); - set->driver_data = &ctrl->ctrl; - set->nr_hw_queues = nctrl->queue_count -1 ; - set->timeout =NVME_IO_TIMEOUT ; - set->nr_maps = nctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ; - ret =blk_mq_alloc_tag_set (set); -if (!ret) - nctrl->tagset = set; -return ret; -} -static void nvme_tcp_free_admin_queue (struct nvme_ctrl *ctrl) {if (to_tcp_ctrl (ctrl)->async_req.pdu) {
@@ -1890,10 +1845,8 @@ static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl)static void nvme_tcp_destroy_io_queues (struct nvme_ctrl *ctrl,bool remove) {nvme_tcp_stop_io_queues (ctrl); -if (remove) { -blk_mq_destroy_queue (ctrl->connect_q); -blk_mq_free_tag_set (ctrl->tagset); - } +if (remove) +nvme_remove_io_tag_set (ctrl);nvme_tcp_free_io_queues (ctrl); }
@@ -1906,13 +1859,12 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)return ret;if (new) { - ret =nvme_tcp_alloc_tag_set (ctrl); + ret =nvme_alloc_io_tag_set (ctrl, &to_tcp_ctrl (ctrl)->tag_set, + &nvme_tcp_mq_ops, +BLK_MQ_F_SHOULD_MERGE |BLK_MQ_F_BLOCKING , +sizeof (struct nvme_tcp_request ));if (ret) goto out_free_io_queues; - - ret =nvme_ctrl_init_connect_q (ctrl); -if (ret) - goto out_free_tag_set; }/*
@@ -1959,10 +1911,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) out_cleanup_connect_q:nvme_cancel_tagset (ctrl);if (new) -blk_mq_destroy_queue (ctrl->connect_q); -out_free_tag_set: -if (new) -blk_mq_free_tag_set (ctrl->tagset); +nvme_remove_io_tag_set (ctrl); out_free_io_queues:nvme_tcp_free_io_queues (ctrl);return ret;
@@ -1971,11 +1920,8 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)static void nvme_tcp_destroy_admin_queue (struct nvme_ctrl *ctrl,bool remove) {nvme_tcp_stop_queue (ctrl,0 ); -if (remove) { -blk_mq_destroy_queue (ctrl->admin_q); -blk_mq_destroy_queue (ctrl->fabrics_q); -blk_mq_free_tag_set (ctrl->admin_tagset); - } +if (remove) +nvme_remove_admin_tag_set (ctrl);nvme_tcp_free_admin_queue (ctrl); }
@@ -1988,26 +1934,17 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)return error;if (new) { - error =nvme_tcp_alloc_admin_tag_set (ctrl); + error =nvme_alloc_admin_tag_set (ctrl, + &to_tcp_ctrl (ctrl)->admin_tag_set, + &nvme_tcp_admin_mq_ops,BLK_MQ_F_BLOCKING , +sizeof (struct nvme_tcp_request ));if (error) goto out_free_queue; - - ctrl->fabrics_q =blk_mq_init_queue (ctrl->admin_tagset); -if (IS_ERR (ctrl->fabrics_q)) { - error =PTR_ERR (ctrl->fabrics_q); - goto out_free_tagset; - } - - ctrl->admin_q =blk_mq_init_queue (ctrl->admin_tagset); -if (IS_ERR (ctrl->admin_q)) { - error =PTR_ERR (ctrl->admin_q); - goto out_cleanup_fabrics_q; - } } error =nvme_tcp_start_queue (ctrl,0 );if (error) - goto out_cleanup_queue; + goto out_cleanup_tagset; error =nvme_enable_ctrl (ctrl);if (error)
@@ -2027,15 +1964,9 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) out_stop_queue:nvme_tcp_stop_queue (ctrl,0 );nvme_cancel_admin_tagset (ctrl); -out_cleanup_queue: -if (new) -blk_mq_destroy_queue (ctrl->admin_q); -out_cleanup_fabrics_q: -if (new) -blk_mq_destroy_queue (ctrl->fabrics_q); -out_free_tagset: +out_cleanup_tagset:if (new) -blk_mq_free_tag_set (ctrl->admin_tagset); +nvme_remove_admin_tag_set (ctrl); out_free_queue:nvme_tcp_free_admin_queue (ctrl);return error;
Signature · 1 line
2.30.2
Re: [PATCH 04/13] nvme-tcp: use the tagset alloc/free helpers
Quoted 5 lines · Christoph Hellwig
Use the common helpers to allocate and free the tagsets. To make this work the generic
nvme_ctrlnow needs to be stored in the hctx private data instead of thenvme_tcp_ctrl.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 04/13] nvme-tcp: use the tagset alloc/free helpers
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 5/13 nvme-rdma: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigPoint the private data to the generic controller structure in preparation of using the common tagset init/exit code.
--- drivers/nvme/host/rdma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/rdma.c +6 -6
@@ -295,7 +295,7 @@ static int nvme_rdma_init_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx, unsigned int numa_node) { - struct nvme_rdma_ctrl *ctrl = set->driver_data; + struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(set->driver_data);struct nvme_rdma_request *req =blk_mq_rq_to_pdu (rq);int queue_idx = (set == &ctrl->tag_set) ? hctx_idx +1 :0 ;struct nvme_rdma_queue *queue = &ctrl->queues[queue_idx];
@@ -320,7 +320,7 @@ static int nvme_rdma_init_request(struct blk_mq_tag_set *set,static int nvme_rdma_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_rdma_ctrl *ctrl = data; +struct nvme_rdma_ctrl *ctrl =to_rdma_ctrl (data);struct nvme_rdma_queue *queue = &ctrl->queues[hctx_idx +1 ];BUG_ON (hctx_idx >= ctrl->ctrl.queue_count);
@@ -332,7 +332,7 @@ static int nvme_rdma_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,static int nvme_rdma_init_admin_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_rdma_ctrl *ctrl = data; +struct nvme_rdma_ctrl *ctrl =to_rdma_ctrl (data);struct nvme_rdma_queue *queue = &ctrl->queues[0 ];BUG_ON (hctx_idx !=0 );
@@ -801,7 +801,7 @@ static int nvme_rdma_alloc_admin_tag_set(struct nvme_ctrl *nctrl) set->numa_node = nctrl->numa_node; set->cmd_size =sizeof (struct nvme_rdma_request ) +NVME_RDMA_DATA_SGL_SIZE ; - set->driver_data = ctrl; + set->driver_data = &ctrl->ctrl; set->nr_hw_queues =1 ; set->timeout =NVME_ADMIN_TIMEOUT ; set->flags =BLK_MQ_F_NO_SCHED ;
@@ -828,7 +828,7 @@ static int nvme_rdma_alloc_tag_set(struct nvme_ctrl *nctrl)if (nctrl->max_integrity_segments) set->cmd_size +=sizeof (struct nvme_rdma_sgl ) +NVME_RDMA_METADATA_SGL_SIZE ; - set->driver_data = ctrl; + set->driver_data = &ctrl->ctrl; set->nr_hw_queues = nctrl->queue_count -1 ; set->timeout =NVME_IO_TIMEOUT ; set->nr_maps = nctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ;
@@ -2206,7 +2206,7 @@ static void nvme_rdma_complete_rq(struct request *rq)static void nvme_rdma_map_queues (struct blk_mq_tag_set *set) { -struct nvme_rdma_ctrl *ctrl = set->driver_data; +struct nvme_rdma_ctrl *ctrl =to_rdma_ctrl (set->driver_data);struct nvmf_ctrl_options *opts = ctrl->ctrl.opts;if (opts->nr_write_queues && ctrl->io_queues[HCTX_TYPE_READ ]) {
Signature · 1 line
2.30.2
Re: [PATCH 05/13] nvme-rdma: store the generic nvme_ctrl in set->driver_data
Quoted 4 lines · Christoph Hellwig
Point the private data to the generic controller structure in preparation of using the common tagset init/exit code.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 05/13] nvme-rdma: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 6/13 nvme-rdma: use the tagset alloc/free helpers
In reply to Christoph HellwigUse the common helpers to allocate and free the tagsets. To make this work the generic nvme_ctrl now needs to be stored in the hctx private data instead of the nvme_rdma_ctrl.
--- drivers/nvme/host/rdma.c | 133 ++++++++++----------------------------- 1 file changed, 34 insertions(+), 99 deletions(-)
drivers/nvme/host/rdma.c +34 -99
@@ -788,64 +788,21 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl)return ret; } -static int nvme_rdma_alloc_admin_tag_set (struct nvme_ctrl *nctrl) +static int nvme_rdma_alloc_tag_set (struct nvme_ctrl *ctrl) { -struct nvme_rdma_ctrl *ctrl =to_rdma_ctrl (nctrl); -struct blk_mq_tag_set *set = &ctrl->admin_tag_set; -int ret; +unsigned int cmd_size =sizeof (struct nvme_rdma_request ) + +NVME_RDMA_DATA_SGL_SIZE ; -memset (set,0 ,sizeof (*set)); - set->ops = &nvme_rdma_admin_mq_ops; - set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ; - set->reserved_tags =NVMF_RESERVED_TAGS ; - set->numa_node = nctrl->numa_node; - set->cmd_size =sizeof (struct nvme_rdma_request ) + -NVME_RDMA_DATA_SGL_SIZE ; - set->driver_data = &ctrl->ctrl; - set->nr_hw_queues =1 ; - set->timeout =NVME_ADMIN_TIMEOUT ; - set->flags =BLK_MQ_F_NO_SCHED ; - ret =blk_mq_alloc_tag_set (set); -if (!ret) - ctrl->ctrl.admin_tagset = set; -return ret; -} - -static int nvme_rdma_alloc_tag_set (struct nvme_ctrl *nctrl) -{ -struct nvme_rdma_ctrl *ctrl =to_rdma_ctrl (nctrl); -struct blk_mq_tag_set *set = &ctrl->tag_set; -int ret; +if (ctrl->max_integrity_segments) + cmd_size +=sizeof (struct nvme_rdma_sgl ) + +NVME_RDMA_METADATA_SGL_SIZE ; -memset (set,0 ,sizeof (*set)); - set->ops = &nvme_rdma_mq_ops; - set->queue_depth = nctrl->sqsize +1 ; - set->reserved_tags =NVMF_RESERVED_TAGS ; - set->numa_node = nctrl->numa_node; - set->flags =BLK_MQ_F_SHOULD_MERGE ; - set->cmd_size =sizeof (struct nvme_rdma_request ) + -NVME_RDMA_DATA_SGL_SIZE ; -if (nctrl->max_integrity_segments) - set->cmd_size +=sizeof (struct nvme_rdma_sgl ) + -NVME_RDMA_METADATA_SGL_SIZE ; - set->driver_data = &ctrl->ctrl; - set->nr_hw_queues = nctrl->queue_count -1 ; - set->timeout =NVME_IO_TIMEOUT ; - set->nr_maps = nctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ; - ret =blk_mq_alloc_tag_set (set); -if (!ret) - ctrl->ctrl.tagset = set; -return ret; +return nvme_alloc_io_tag_set (ctrl, &to_rdma_ctrl (ctrl)->tag_set, + &nvme_rdma_mq_ops,BLK_MQ_F_SHOULD_MERGE , cmd_size); } -static void nvme_rdma_destroy_admin_queue (struct nvme_rdma_ctrl *ctrl, -bool remove) +static void nvme_rdma_destroy_admin_queue (struct nvme_rdma_ctrl *ctrl) { -if (remove) { -blk_mq_destroy_queue (ctrl->ctrl.admin_q); -blk_mq_destroy_queue (ctrl->ctrl.fabrics_q); -blk_mq_free_tag_set (ctrl->ctrl.admin_tagset); - }if (ctrl->async_event_sqe.data) {cancel_work_sync (&ctrl->ctrl.async_event_work); nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
@@ -887,26 +844,19 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, goto out_free_queue;if (new) { - error =nvme_rdma_alloc_admin_tag_set (&ctrl->ctrl); + error =nvme_alloc_admin_tag_set (&ctrl->ctrl, + &ctrl->admin_tag_set, &nvme_rdma_admin_mq_ops, +BLK_MQ_F_NO_SCHED , +sizeof (struct nvme_rdma_request ) + +NVME_RDMA_DATA_SGL_SIZE );if (error) goto out_free_async_qe; - ctrl->ctrl.fabrics_q =blk_mq_init_queue (&ctrl->admin_tag_set); -if (IS_ERR (ctrl->ctrl.fabrics_q)) { - error =PTR_ERR (ctrl->ctrl.fabrics_q); - goto out_free_tagset; - } - - ctrl->ctrl.admin_q =blk_mq_init_queue (&ctrl->admin_tag_set); -if (IS_ERR (ctrl->ctrl.admin_q)) { - error =PTR_ERR (ctrl->ctrl.admin_q); - goto out_cleanup_fabrics_q; - } } error =nvme_rdma_start_queue (ctrl,0 );if (error) - goto out_cleanup_queue; + goto out_remove_admin_tag_set; error =nvme_enable_ctrl (&ctrl->ctrl);if (error)
@@ -933,15 +883,9 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, out_stop_queue:nvme_rdma_stop_queue (&ctrl->queues[0 ]);nvme_cancel_admin_tagset (&ctrl->ctrl); -out_cleanup_queue: +out_remove_admin_tag_set:if (new) -blk_mq_destroy_queue (ctrl->ctrl.admin_q); -out_cleanup_fabrics_q: -if (new) -blk_mq_destroy_queue (ctrl->ctrl.fabrics_q); -out_free_tagset: -if (new) -blk_mq_free_tag_set (ctrl->ctrl.admin_tagset); +nvme_remove_admin_tag_set (&ctrl->ctrl); out_free_async_qe:if (ctrl->async_event_sqe.data) { nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
@@ -953,16 +897,6 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,return error; } -static void nvme_rdma_destroy_io_queues (struct nvme_rdma_ctrl *ctrl, -bool remove) -{ -if (remove) { -blk_mq_destroy_queue (ctrl->ctrl.connect_q); -blk_mq_free_tag_set (ctrl->ctrl.tagset); - } -nvme_rdma_free_io_queues (ctrl); -} -static int nvme_rdma_configure_io_queues (struct nvme_rdma_ctrl *ctrl,bool new) {int ret, nr_queues;
@@ -975,10 +909,6 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) ret =nvme_rdma_alloc_tag_set (&ctrl->ctrl);if (ret) goto out_free_io_queues; - - ret =nvme_ctrl_init_connect_q (&(ctrl->ctrl)); -if (ret) - goto out_free_tag_set; }/*
@@ -989,7 +919,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) nr_queues =min (ctrl->tag_set.nr_hw_queues +1 , ctrl->ctrl.queue_count); ret =nvme_rdma_start_io_queues (ctrl,1 , nr_queues);if (ret) - goto out_cleanup_connect_q; + goto out_cleanup_tagset;if (!new) {nvme_start_queues (&ctrl->ctrl);
@@ -1022,13 +952,10 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)nvme_stop_queues (&ctrl->ctrl);nvme_sync_io_queues (&ctrl->ctrl);nvme_rdma_stop_io_queues (ctrl); -out_cleanup_connect_q: +out_cleanup_tagset:nvme_cancel_tagset (&ctrl->ctrl);if (new) -blk_mq_destroy_queue (ctrl->ctrl.connect_q); -out_free_tag_set: -if (new) -blk_mq_free_tag_set (ctrl->ctrl.tagset); +nvme_remove_io_tag_set (&ctrl->ctrl); out_free_io_queues:nvme_rdma_free_io_queues (ctrl);return ret;
@@ -1041,9 +968,11 @@ static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl,blk_sync_queue (ctrl->ctrl.admin_q);nvme_rdma_stop_queue (&ctrl->queues[0 ]);nvme_cancel_admin_tagset (&ctrl->ctrl); -if (remove) +if (remove) {nvme_start_admin_queue (&ctrl->ctrl); -nvme_rdma_destroy_admin_queue (ctrl, remove); +nvme_remove_admin_tag_set (&ctrl->ctrl); + } +nvme_rdma_destroy_admin_queue (ctrl); } static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
@@ -1055,9 +984,11 @@ static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,nvme_sync_io_queues (&ctrl->ctrl);nvme_rdma_stop_io_queues (ctrl);nvme_cancel_tagset (&ctrl->ctrl); -if (remove) +if (remove) {nvme_start_queues (&ctrl->ctrl); -nvme_rdma_destroy_io_queues (ctrl, remove); +nvme_remove_io_tag_set (&ctrl->ctrl); + } +nvme_rdma_free_io_queues (ctrl); } }
@@ -1179,14 +1110,18 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)nvme_sync_io_queues (&ctrl->ctrl);nvme_rdma_stop_io_queues (ctrl);nvme_cancel_tagset (&ctrl->ctrl); -nvme_rdma_destroy_io_queues (ctrl, new); +if (new) +nvme_remove_io_tag_set (&ctrl->ctrl); +nvme_rdma_free_io_queues (ctrl); } destroy_admin:nvme_stop_admin_queue (&ctrl->ctrl);blk_sync_queue (ctrl->ctrl.admin_q);nvme_rdma_stop_queue (&ctrl->queues[0 ]);nvme_cancel_admin_tagset (&ctrl->ctrl); -nvme_rdma_destroy_admin_queue (ctrl, new); +if (new) +nvme_remove_admin_tag_set (&ctrl->ctrl); +nvme_rdma_destroy_admin_queue (ctrl);return ret; }
Signature · 1 line
2.30.2
Re: [PATCH 06/13] nvme-rdma: use the tagset alloc/free helpers
Quoted 5 lines · Christoph Hellwig
Use the common helpers to allocate and free the tagsets. To make this work the generic
nvme_ctrlnow needs to be stored in the hctx private data instead of thenvme_rdma_ctrl.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 06/13] nvme-rdma: use the tagset alloc/free helpers
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 7/13 nvme-fc: keep ctrl->sqsize in sync with opts->queue_size
In reply to Christoph HellwigAlso update the sqsize field when capping the queue size, and remove the check a queue size that is larger than sqsize given that sqsize is only initialized from opts->queue_size.
--- drivers/nvme/host/fc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/nvme/host/fc.c +1 -9
@@ -3165,15 +3165,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)"to maxcmd\n" , opts->queue_size, ctrl->ctrl.maxcmd); opts->queue_size = ctrl->ctrl.maxcmd; - } - -if (opts->queue_size > ctrl->ctrl.sqsize +1 ) { -/* warn if sqsize is lower than queue_size */ -dev_warn (ctrl->ctrl.device, -"queue_size %zu > ctrl sqsize %u, reducing " -"to sqsize\n" , - opts->queue_size, ctrl->ctrl.sqsize +1 ); - opts->queue_size = ctrl->ctrl.sqsize +1 ; + ctrl->ctrl.sqsize = opts->queue_size -1 ; } ret =nvme_fc_init_aen_ops (ctrl);
Signature · 1 line
2.30.2
Re: [PATCH 07/13] nvme-fc: keep ctrl->sqsize in sync with opts->queue_size
Re: [PATCH 07/13] nvme-fc: keep ctrl->sqsize in sync with opts->queue_size
In reply to Christoph Hellwigdrivers/nvme/host/fc.c
Quoted 11 lines · Christoph Hellwig
Also update the sqsize field when capping the queue size, and remove the check a queue size that is larger than sqsize given that sqsize is only initialized from
opts->queue_size.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/fc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/nvme/host/fc.c +0
-0
-- james
Christoph Hellwig
maintainerPATCH 8/13 nvme-fc: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigPoint 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.
--- drivers/nvme/host/fc.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
drivers/nvme/host/fc.c +12 -20
@@ -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); -return __nvme_fc_exit_request (set->driver_data, op); +return __nvme_fc_exit_request (to_fc_ctrl (set->driver_data), op); } static int
@@ -2135,7 +2135,7 @@ static int nvme_fc_init_request(struct blk_mq_tag_set *set, struct request *rq, 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);int queue_idx = (set == &ctrl->tag_set) ? hctx_idx +1 :0 ;struct nvme_fc_queue *queue = &ctrl->queues[queue_idx];
@@ -2206,36 +2206,28 @@ nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl) } } -static inline void -__nvme_fc_init_hctx (struct blk_mq_hw_ctx *hctx,struct nvme_fc_ctrl *ctrl, -unsigned int qidx) +static inline int +__nvme_fc_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int qidx) { +struct nvme_fc_ctrl *ctrl =to_fc_ctrl (data);struct nvme_fc_queue *queue = &ctrl->queues[qidx]; hctx->driver_data = queue; queue->hctx = hctx; +return 0 ; }static int -nvme_fc_init_hctx (struct blk_mq_hw_ctx *hctx,void *data, -unsigned int hctx_idx) +nvme_fc_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_fc_ctrl *ctrl = data; - -__nvme_fc_init_hctx (hctx, ctrl, hctx_idx +1 ); - -return 0 ; +return __nvme_fc_init_hctx (hctx, data, hctx_idx +1 ); }static int nvme_fc_init_admin_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_fc_ctrl *ctrl = data; - -__nvme_fc_init_hctx (hctx, ctrl, hctx_idx); - -return 0 ; +return __nvme_fc_init_hctx (hctx, data, hctx_idx); } static void
@@ -2862,7 +2854,7 @@ nvme_fc_complete_rq(struct request *rq)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;for (i =0 ; i < set->nr_maps; i++) {
@@ -2923,7 +2915,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) ctrl->tag_set.cmd_size =struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, 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.timeout =NVME_IO_TIMEOUT ;
@@ -3546,7 +3538,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, ctrl->admin_tag_set.cmd_size =struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, 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.timeout =NVME_ADMIN_TIMEOUT ; ctrl->admin_tag_set.flags =BLK_MQ_F_NO_SCHED ;
Signature · 1 line
2.30.2
Re: [PATCH 08/13] nvme-fc: store the generic nvme_ctrl in set->driver_data
Re: [PATCH 08/13] nvme-fc: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
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_hctxmethods a bit.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/fc.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
-- james
Christoph Hellwig
maintainerPATCH 9/13 nvme-fc: use the tagset alloc/free helpers
In reply to Christoph HellwigUse the common helpers to allocate and free the tagsets. To make this work the generic nvme_ctrl now needs to be stored in the hctx private data instead of the nvme_fc_ctrl.
--- drivers/nvme/host/fc.c | 83 +++++++++--------------------------------- 1 file changed, 17 insertions(+), 66 deletions(-)
drivers/nvme/host/fc.c +17 -66
@@ -2383,10 +2383,8 @@ nvme_fc_ctrl_free(struct kref *ref) container_of(ref, struct nvme_fc_ctrl, ref);unsigned long flags; -if (ctrl->ctrl.tagset) { -blk_mq_destroy_queue (ctrl->ctrl.connect_q); -blk_mq_free_tag_set (&ctrl->tag_set); - } +if (ctrl->ctrl.tagset) +nvme_remove_io_tag_set (&ctrl->ctrl);/* remove from rport list */ spin_lock_irqsave (&ctrl->rport->lock, flags);
@@ -2394,9 +2392,7 @@ nvme_fc_ctrl_free(struct kref *ref)spin_unlock_irqrestore (&ctrl->rport->lock, flags);nvme_start_admin_queue (&ctrl->ctrl); -blk_mq_destroy_queue (ctrl->ctrl.admin_q); -blk_mq_destroy_queue (ctrl->ctrl.fabrics_q); -blk_mq_free_tag_set (&ctrl->admin_tag_set); +nvme_remove_admin_tag_set (&ctrl->ctrl);kfree (ctrl->queues);
@@ -2906,32 +2902,16 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)nvme_fc_init_io_queues (ctrl); -memset (&ctrl->tag_set,0 ,sizeof (ctrl->tag_set)); - ctrl->tag_set.ops = &nvme_fc_mq_ops; - ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; - ctrl->tag_set.reserved_tags =NVMF_RESERVED_TAGS ; - ctrl->tag_set.numa_node = ctrl->ctrl.numa_node; - ctrl->tag_set.flags =BLK_MQ_F_SHOULD_MERGE ; - ctrl->tag_set.cmd_size = -struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, - ctrl->lport->ops->fcprqst_priv_sz); - ctrl->tag_set.driver_data = &ctrl->ctrl; - ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count -1 ; - ctrl->tag_set.timeout =NVME_IO_TIMEOUT ; - - ret =blk_mq_alloc_tag_set (&ctrl->tag_set); + ret =nvme_alloc_io_tag_set (&ctrl->ctrl, &ctrl->tag_set, + &nvme_fc_mq_ops,BLK_MQ_F_SHOULD_MERGE , +struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, + ctrl->lport->ops->fcprqst_priv_sz));if (ret)return ret; - ctrl->ctrl.tagset = &ctrl->tag_set; - - ret =nvme_ctrl_init_connect_q (&(ctrl->ctrl)); -if (ret) - goto out_free_tag_set; - ret =nvme_fc_create_hw_io_queues (ctrl, ctrl->ctrl.sqsize +1 );if (ret) - goto out_cleanup_blk_queue; + goto out_cleanup_tagset; ret =nvme_fc_connect_io_queues (ctrl, ctrl->ctrl.sqsize +1 );if (ret)
@@ -2943,10 +2923,8 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) out_delete_hw_queues:nvme_fc_delete_hw_io_queues (ctrl); -out_cleanup_blk_queue: -blk_mq_destroy_queue (ctrl->ctrl.connect_q); -out_free_tag_set: -blk_mq_free_tag_set (&ctrl->tag_set); +out_cleanup_tagset: +nvme_remove_io_tag_set (&ctrl->ctrl);nvme_fc_free_io_queues (ctrl);/* force put free routine to ignore io queues */
@@ -3530,35 +3508,12 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,nvme_fc_init_queue (ctrl,0 ); -memset (&ctrl->admin_tag_set,0 ,sizeof (ctrl->admin_tag_set)); - ctrl->admin_tag_set.ops = &nvme_fc_admin_mq_ops; - ctrl->admin_tag_set.queue_depth =NVME_AQ_MQ_TAG_DEPTH ; - ctrl->admin_tag_set.reserved_tags =NVMF_RESERVED_TAGS ; - ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node; - ctrl->admin_tag_set.cmd_size = -struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, - ctrl->lport->ops->fcprqst_priv_sz); - ctrl->admin_tag_set.driver_data = &ctrl->ctrl; - ctrl->admin_tag_set.nr_hw_queues =1 ; - ctrl->admin_tag_set.timeout =NVME_ADMIN_TIMEOUT ; - ctrl->admin_tag_set.flags =BLK_MQ_F_NO_SCHED ; - - ret =blk_mq_alloc_tag_set (&ctrl->admin_tag_set); + ret =nvme_alloc_admin_tag_set (&ctrl->ctrl, &ctrl->admin_tag_set, + &nvme_fc_admin_mq_ops,BLK_MQ_F_NO_SCHED , +struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, + ctrl->lport->ops->fcprqst_priv_sz));if (ret) goto out_free_queues; - ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set; - - ctrl->ctrl.fabrics_q =blk_mq_init_queue (&ctrl->admin_tag_set); -if (IS_ERR (ctrl->ctrl.fabrics_q)) { - ret =PTR_ERR (ctrl->ctrl.fabrics_q); - goto out_free_admin_tag_set; - } - - ctrl->ctrl.admin_q =blk_mq_init_queue (&ctrl->admin_tag_set); -if (IS_ERR (ctrl->ctrl.admin_q)) { - ret =PTR_ERR (ctrl->ctrl.admin_q); - goto out_cleanup_fabrics_q; - }/* * Would have been nice to init io queues tag set as well.
@@ -3569,7 +3524,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, ret =nvme_init_ctrl (&ctrl->ctrl, dev, &nvme_fc_ctrl_ops,0 );if (ret) - goto out_cleanup_admin_q; + goto out_cleanup_tagset;/* at this point, teardown path changes to ref counting on nvme ctrl */
@@ -3624,12 +3579,8 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,return ERR_PTR (-EIO ); -out_cleanup_admin_q: -blk_mq_destroy_queue (ctrl->ctrl.admin_q); -out_cleanup_fabrics_q: -blk_mq_destroy_queue (ctrl->ctrl.fabrics_q); -out_free_admin_tag_set: -blk_mq_free_tag_set (&ctrl->admin_tag_set); +out_cleanup_tagset: +nvme_remove_admin_tag_set (&ctrl->ctrl); out_free_queues:kfree (ctrl->queues); out_free_ida:
Signature · 1 line
2.30.2
Re: [PATCH 09/13] nvme-fc: use the tagset alloc/free helpers
Re: [PATCH 09/13] nvme-fc: use the tagset alloc/free helpers
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
Use the common helpers to allocate and free the tagsets. To make this work the generic
nvme_ctrlnow needs to be stored in the hctx private data instead of thenvme_fc_ctrl.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/fc.c | 83 +++++++++--------------------------------- 1 file changed, 17 insertions(+), 66 deletions(-)
-- james
Christoph Hellwig
maintainerPATCH 10/13 nvme-loop: initialize sqsize later
In reply to Christoph HellwigDefer initializing the sqsize field from the options until it has been capped by MAXCMD.
--- drivers/nvme/target/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/loop.c +1 -1
@@ -601,7 +601,6 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, ret = -ENOMEM ; - ctrl->ctrl.sqsize = opts->queue_size -1 ; ctrl->ctrl.kato = opts->kato; ctrl->port =nvme_loop_find_port (&ctrl->ctrl);
@@ -621,6 +620,7 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, opts->queue_size, ctrl->ctrl.maxcmd); opts->queue_size = ctrl->ctrl.maxcmd; } + ctrl->ctrl.sqsize = opts->queue_size -1 ;if (opts->nr_io_queues) { ret =nvme_loop_create_io_queues (ctrl);
Signature · 1 line
2.30.2
Re: [PATCH 10/13] nvme-loop: initialize sqsize later
Quoted 4 lines · Christoph Hellwig
Defer initializing the sqsize field from the options until it has been capped by MAXCMD.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 10/13] nvme-loop: initialize sqsize later
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 11/13 nvme-loop: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigPoint the private data to the generic controller structure in preparation of using the common tagset init/exit code.
--- drivers/nvme/target/loop.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/nvme/target/loop.c +5 -5
@@ -204,7 +204,7 @@ static int nvme_loop_init_request(struct blk_mq_tag_set *set, struct request *req, unsigned int hctx_idx, unsigned int numa_node) { - struct nvme_loop_ctrl *ctrl = set->driver_data; + struct nvme_loop_ctrl *ctrl = to_loop_ctrl(set->driver_data);struct nvme_loop_iod *iod =blk_mq_rq_to_pdu (req);nvme_req (req)->ctrl = &ctrl->ctrl;
@@ -218,7 +218,7 @@ static struct lock_class_key loop_hctx_fq_lock_key;static int nvme_loop_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_loop_ctrl *ctrl = data; +struct nvme_loop_ctrl *ctrl =to_loop_ctrl (data);struct nvme_loop_queue *queue = &ctrl->queues[hctx_idx +1 ];BUG_ON (hctx_idx >= ctrl->ctrl.queue_count);
@@ -238,7 +238,7 @@ static int nvme_loop_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,static int nvme_loop_init_admin_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_loop_ctrl *ctrl = data; +struct nvme_loop_ctrl *ctrl =to_loop_ctrl (data);struct nvme_loop_queue *queue = &ctrl->queues[0 ];BUG_ON (hctx_idx !=0 );
@@ -357,7 +357,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node; ctrl->admin_tag_set.cmd_size =sizeof (struct nvme_loop_iod ) +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ); - 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.timeout =NVME_ADMIN_TIMEOUT ; ctrl->admin_tag_set.flags =BLK_MQ_F_NO_SCHED ;
@@ -530,7 +530,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl) ctrl->tag_set.flags =BLK_MQ_F_SHOULD_MERGE ; ctrl->tag_set.cmd_size =sizeof (struct nvme_loop_iod ) +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ); - 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.timeout =NVME_IO_TIMEOUT ; ctrl->ctrl.tagset = &ctrl->tag_set;
Signature · 1 line
2.30.2
Re: [PATCH 11/13] nvme-loop: store the generic nvme_ctrl in set->driver_data
Quoted 5 lines · Christoph Hellwig
Point the private data to the generic controller structure in preparation of using the common tagset init/exit code.
Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
Re: [PATCH 11/13] nvme-loop: store the generic nvme_ctrl in set->driver_data
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 12/13 nvme-loop: use the tagset alloc/free helpers
In reply to Christoph HellwigUse the common helpers to allocate and free the tagsets. To make this work the generic nvme_ctrl now needs to be stored in the hctx private data instead of the nvme_loop_ctrl.
--- drivers/nvme/target/loop.c | 83 +++++++++----------------------------- 1 file changed, 19 insertions(+), 64 deletions(-)
drivers/nvme/target/loop.c +19 -64
@@ -266,9 +266,7 @@ static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl)if (!test_and_clear_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags))return ;nvmet_sq_destroy (&ctrl->queues[0 ].nvme_sq); -blk_mq_destroy_queue (ctrl->ctrl.admin_q); -blk_mq_destroy_queue (ctrl->ctrl.fabrics_q); -blk_mq_free_tag_set (&ctrl->admin_tag_set); +nvme_remove_admin_tag_set (&ctrl->ctrl); }static void nvme_loop_free_ctrl (struct nvme_ctrl *nctrl)
@@ -282,10 +280,8 @@ static void nvme_loop_free_ctrl(struct nvme_ctrl *nctrl)list_del (&ctrl->list);mutex_unlock (&nvme_loop_ctrl_mutex); -if (nctrl->tagset) { -blk_mq_destroy_queue (ctrl->ctrl.connect_q); -blk_mq_free_tag_set (&ctrl->tag_set); - } +if (nctrl->tagset) +nvme_remove_io_tag_set (nctrl);kfree (ctrl->queues);nvmf_free_options (nctrl->opts); free_ctrl:
@@ -350,52 +346,31 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) {int error; -memset (&ctrl->admin_tag_set,0 ,sizeof (ctrl->admin_tag_set)); - ctrl->admin_tag_set.ops = &nvme_loop_admin_mq_ops; - ctrl->admin_tag_set.queue_depth =NVME_AQ_MQ_TAG_DEPTH ; - ctrl->admin_tag_set.reserved_tags =NVMF_RESERVED_TAGS ; - ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node; - ctrl->admin_tag_set.cmd_size =sizeof (struct nvme_loop_iod ) + -NVME_INLINE_SG_CNT *sizeof (struct scatterlist ); - ctrl->admin_tag_set.driver_data = &ctrl->ctrl; - ctrl->admin_tag_set.nr_hw_queues =1 ; - ctrl->admin_tag_set.timeout =NVME_ADMIN_TIMEOUT ; - ctrl->admin_tag_set.flags =BLK_MQ_F_NO_SCHED ; - ctrl->queues[0 ].ctrl = ctrl; error =nvmet_sq_init (&ctrl->queues[0 ].nvme_sq);if (error)return error; ctrl->ctrl.queue_count =1 ; - error =blk_mq_alloc_tag_set (&ctrl->admin_tag_set); + error =nvme_alloc_admin_tag_set (&ctrl->ctrl, &ctrl->admin_tag_set, + &nvme_loop_admin_mq_ops,BLK_MQ_F_NO_SCHED , +sizeof (struct nvme_loop_iod ) + +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ));if (error) goto out_free_sq; - ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set; - - ctrl->ctrl.fabrics_q =blk_mq_init_queue (&ctrl->admin_tag_set); -if (IS_ERR (ctrl->ctrl.fabrics_q)) { - error =PTR_ERR (ctrl->ctrl.fabrics_q); - goto out_free_tagset; - } - ctrl->ctrl.admin_q =blk_mq_init_queue (&ctrl->admin_tag_set); -if (IS_ERR (ctrl->ctrl.admin_q)) { - error =PTR_ERR (ctrl->ctrl.admin_q); - goto out_cleanup_fabrics_q; - }/* reset stopped state for the fresh admin queue */ clear_bit (NVME_CTRL_ADMIN_Q_STOPPED , &ctrl->ctrl.flags); error =nvmf_connect_admin_queue (&ctrl->ctrl);if (error) - goto out_cleanup_queue; + goto out_cleanup_tagset;set_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags); error =nvme_enable_ctrl (&ctrl->ctrl);if (error) - goto out_cleanup_queue; + goto out_cleanup_tagset; ctrl->ctrl.max_hw_sectors = (NVME_LOOP_MAX_SEGMENTS -1 ) << (PAGE_SHIFT -9 );
@@ -404,17 +379,13 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) error =nvme_init_ctrl_finish (&ctrl->ctrl);if (error) - goto out_cleanup_queue; + goto out_cleanup_tagset;return 0 ; -out_cleanup_queue: +out_cleanup_tagset:clear_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags); -blk_mq_destroy_queue (ctrl->ctrl.admin_q); -out_cleanup_fabrics_q: -blk_mq_destroy_queue (ctrl->ctrl.fabrics_q); -out_free_tagset: -blk_mq_free_tag_set (&ctrl->admin_tag_set); +nvme_remove_admin_tag_set (&ctrl->ctrl); out_free_sq:nvmet_sq_destroy (&ctrl->queues[0 ].nvme_sq);return error;
@@ -522,37 +493,21 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)if (ret)return ret; -memset (&ctrl->tag_set,0 ,sizeof (ctrl->tag_set)); - ctrl->tag_set.ops = &nvme_loop_mq_ops; - ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; - ctrl->tag_set.reserved_tags =NVMF_RESERVED_TAGS ; - ctrl->tag_set.numa_node = ctrl->ctrl.numa_node; - ctrl->tag_set.flags =BLK_MQ_F_SHOULD_MERGE ; - ctrl->tag_set.cmd_size =sizeof (struct nvme_loop_iod ) + -NVME_INLINE_SG_CNT *sizeof (struct scatterlist ); - ctrl->tag_set.driver_data = &ctrl->ctrl; - ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count -1 ; - ctrl->tag_set.timeout =NVME_IO_TIMEOUT ; - ctrl->ctrl.tagset = &ctrl->tag_set; - - ret =blk_mq_alloc_tag_set (&ctrl->tag_set); + ret =nvme_alloc_io_tag_set (&ctrl->ctrl, &ctrl->tag_set, + &nvme_loop_mq_ops,BLK_MQ_F_SHOULD_MERGE , +sizeof (struct nvme_loop_iod ) + +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ));if (ret) goto out_destroy_queues; - ret =nvme_ctrl_init_connect_q (&(ctrl->ctrl)); -if (ret) - goto out_free_tagset; - ret =nvme_loop_connect_io_queues (ctrl);if (ret) - goto out_cleanup_connect_q; + goto out_cleanup_tagset;return 0 ; -out_cleanup_connect_q: -blk_mq_destroy_queue (ctrl->ctrl.connect_q); -out_free_tagset: -blk_mq_free_tag_set (&ctrl->tag_set); +out_cleanup_tagset: +nvme_remove_io_tag_set (&ctrl->ctrl); out_destroy_queues:nvme_loop_destroy_io_queues (ctrl);return ret;
Signature · 1 line
2.30.2
Re: [PATCH 12/13] nvme-loop: use the tagset alloc/free helpers
Quoted 6 lines · Christoph Hellwig
Use the common helpers to allocate and free the tagsets. To make this work the generic
nvme_ctrlnow needs to be stored in the hctx private data instead of thenvme_loop_ctrl.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
Re: [PATCH 12/13] nvme-loop: use the tagset alloc/free helpers
In reply to Christoph HellwigChristoph Hellwig
maintainerPATCH 13/13 nvme: remove nvme_ctrl_init_connect_q
In reply to Christoph HellwigUnused now.
--- drivers/nvme/host/nvme.h | 8 -------- 1 file changed, 8 deletions(-)
drivers/nvme/host/nvme.h +0 -8
@@ -976,14 +976,6 @@ static inline int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) }#endif -static inline int nvme_ctrl_init_connect_q (struct nvme_ctrl *ctrl) -{ - ctrl->connect_q =blk_mq_init_queue (ctrl->tagset); -if (IS_ERR (ctrl->connect_q)) -return PTR_ERR (ctrl->connect_q); -return 0 ; -} -static inline struct nvme_ns *nvme_get_ns_from_dev (struct device *dev) {return dev_to_disk (dev)->private_data;
Signature · 1 line
2.30.2
Re: [PATCH 13/13] nvme: remove nvme_ctrl_init_connect_q
Quoted 4 lines · Christoph Hellwig
Unused now.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Re: [PATCH 13/13] nvme: remove nvme_ctrl_init_connect_q
In reply to Christoph HellwigChristoph Hellwig
maintainerI've pulled this series into nvme-6.1 with the additional F_FABRICS check pointed out by Sagi.
Quoted 3 lines
I've pulled this series into nvme-6.1 with the additional
F_FABRICScheck pointed out by Sagi.
You can add my: