diff options
author | Sagi Grimberg <sagi@grimberg.me> | 2017-06-29 04:16:49 -0400 |
---|---|---|
committer | Sagi Grimberg <sagi@grimberg.me> | 2017-07-04 02:43:26 -0400 |
commit | 7314183d1d0c200def4d0f5a6d978d3b29d28813 (patch) | |
tree | 9328c3e0f507e4cc494ffb2b2fa8ba72068e2a12 | |
parent | 01ad0990467eaa17ae17db7376a4f02739f558c0 (diff) |
nvme-fc: don't override opts->nr_io_queues
Its what the user passed, so its probably a better
idea to keep it intact. Also, limit the number of
I/O queues to max online cpus and the lport maximum
hw queues.
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
-rw-r--r-- | drivers/nvme/host/fc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 2f990d979037..996720043b3a 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c | |||
@@ -2175,17 +2175,20 @@ static int | |||
2175 | nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) | 2175 | nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) |
2176 | { | 2176 | { |
2177 | struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; | 2177 | struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; |
2178 | unsigned int nr_io_queues; | ||
2178 | int ret; | 2179 | int ret; |
2179 | 2180 | ||
2180 | ret = nvme_set_queue_count(&ctrl->ctrl, &opts->nr_io_queues); | 2181 | nr_io_queues = min(min(opts->nr_io_queues, num_online_cpus()), |
2182 | ctrl->lport->ops->max_hw_queues); | ||
2183 | ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); | ||
2181 | if (ret) { | 2184 | if (ret) { |
2182 | dev_info(ctrl->ctrl.device, | 2185 | dev_info(ctrl->ctrl.device, |
2183 | "set_queue_count failed: %d\n", ret); | 2186 | "set_queue_count failed: %d\n", ret); |
2184 | return ret; | 2187 | return ret; |
2185 | } | 2188 | } |
2186 | 2189 | ||
2187 | ctrl->ctrl.queue_count = opts->nr_io_queues + 1; | 2190 | ctrl->ctrl.queue_count = nr_io_queues + 1; |
2188 | if (!opts->nr_io_queues) | 2191 | if (!nr_io_queues) |
2189 | return 0; | 2192 | return 0; |
2190 | 2193 | ||
2191 | nvme_fc_init_io_queues(ctrl); | 2194 | nvme_fc_init_io_queues(ctrl); |
@@ -2245,15 +2248,19 @@ static int | |||
2245 | nvme_fc_reinit_io_queues(struct nvme_fc_ctrl *ctrl) | 2248 | nvme_fc_reinit_io_queues(struct nvme_fc_ctrl *ctrl) |
2246 | { | 2249 | { |
2247 | struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; | 2250 | struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; |
2251 | unsigned int nr_io_queues; | ||
2248 | int ret; | 2252 | int ret; |
2249 | 2253 | ||
2250 | ret = nvme_set_queue_count(&ctrl->ctrl, &opts->nr_io_queues); | 2254 | nr_io_queues = min(min(opts->nr_io_queues, num_online_cpus()), |
2255 | ctrl->lport->ops->max_hw_queues); | ||
2256 | ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); | ||
2251 | if (ret) { | 2257 | if (ret) { |
2252 | dev_info(ctrl->ctrl.device, | 2258 | dev_info(ctrl->ctrl.device, |
2253 | "set_queue_count failed: %d\n", ret); | 2259 | "set_queue_count failed: %d\n", ret); |
2254 | return ret; | 2260 | return ret; |
2255 | } | 2261 | } |
2256 | 2262 | ||
2263 | ctrl->ctrl.queue_count = nr_io_queues + 1; | ||
2257 | /* check for io queues existing */ | 2264 | /* check for io queues existing */ |
2258 | if (ctrl->ctrl.queue_count == 1) | 2265 | if (ctrl->ctrl.queue_count == 1) |
2259 | return 0; | 2266 | return 0; |
@@ -2702,7 +2709,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, | |||
2702 | ctrl->ctrl.queue_count = min_t(unsigned int, | 2709 | ctrl->ctrl.queue_count = min_t(unsigned int, |
2703 | opts->nr_io_queues, | 2710 | opts->nr_io_queues, |
2704 | lport->ops->max_hw_queues); | 2711 | lport->ops->max_hw_queues); |
2705 | opts->nr_io_queues = ctrl->ctrl.queue_count; /* so opts has valid value */ | ||
2706 | ctrl->ctrl.queue_count++; /* +1 for admin queue */ | 2712 | ctrl->ctrl.queue_count++; /* +1 for admin queue */ |
2707 | 2713 | ||
2708 | ctrl->ctrl.sqsize = opts->queue_size - 1; | 2714 | ctrl->ctrl.sqsize = opts->queue_size - 1; |