2016-06-06 21:44:30 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
nvmf/rdma: Add shared receive queue support
This is a new feature for NVMEoF RDMA target, that is intended to save
resource allocation (by sharing them) and utilize the
locality (completions and memory) to get the best performance with
Shared Receive Queues (SRQs). We'll create a SRQ per core (poll
group), per device and associate each created QP/CQ with an
appropriate SRQ.
Our testing environment has 2 hosts.
Host 1:
CPU: Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz dual socket (8 cores total)
Network: ConnectX-5, ConnectX-5 VPI , 100GbE, single-port QSFP28, PCIe3.0 x16
Disk: Intel Optane SSD 900P Series
OS: Fedora 27 x86_64
Host 2:
CPU: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz dual-socket (24 cores total)
Network: ConnectX-4 VPI , 100GbE, dual-port QSFP28
Disk: Intel Optane SSD 900P Series
OS : CentOS 7.5.1804 x86_64
Hosts are connected via Spectrum switch.
Host 1 is running SPDK NVMeoF target.
Host 2 is used as initiator running fio with SPDK plugin.
Configuration:
- SPDK NVMeoF target: cpu mask 0x0F (4 cores), max queue depth 128,
max SRQ depth 1024, max QPs per controller 1024
- Single NVMf subsystem with single namespace backed by physical SSD disk
- fio with SPDK plugin: randread pattern, 1-256 jobs, block size 4k,
IO depth 16, cpu_mask 0xFFF0, IO rate 10k, rate process “poisson”
Here is a full fio command line:
fio --name=Job --stats=1 --group_reporting=1 --idle-prof=percpu \
--loops=1 --numjobs=1 --thread=1 --time_based=1 --runtime=30s \
--ramp_time=5s --bs=4k --size=4G --iodepth=16 --readwrite=randread \
--rwmixread=75 --randrepeat=1 --ioengine=spdk --direct=1 \
--gtod_reduce=0 --cpumask=0xFFF0 --rate_iops=10k \
--rate_process=poisson \
--filename='trtype=RDMA adrfam=IPv4 traddr=1.1.79.1 trsvcid=4420 ns=1'
SPDK allocates the following entities for every work request in
receive queue (shared or not): reqs (1024 bytes), recvs (96 bytes),
cmds (64 bytes), cpls (16 bytes), in_capsule_buffer. All except the
last one are fixed size. In capsule data size is configured to 4096.
Memory consumption calculation (target):
- Multiple SRQ: core_num * ib_devs_num * SRQ_depth * (1200 +
in_capsule_data_size)
- Multiple RQ: queue_num * RQ_depth * (1200 + in_capsule_data_size)
We ignore admin queues in calculations for simplicity.
Cases:
1. Multiple SRQ with 1024 entries:
- Mem = 4 * 1 * 1024 * (1200 + 4096) = 20.7 MiB
(Constant number – does not depend on initiators number)
2. RQ with 128 entries for 64 initiators:
- Mem = 64 * 128 * (1200 + 4096) = 41.4 MiB
Results:
FIO_JOBS kIOPS Bandwidth,MiB/s AvgLatency,us MaxResidentSize,kiB
RQ SRQ RQ SRQ RQ SRQ RQ SRQ
1 8.623 8.623 33.7 33.7 13.89 14.03 144376 155624
2 17.3 17.3 67.4 67.4 14.03 14.1 145776 155700
4 34.5 34.5 135 135 14.15 14.23 146540 156184
8 69.1 69.1 270 270 14.64 14.49 148116 156960
16 138 138 540 540 14.84 15.38 151216 158668
32 276 276 1079 1079 16.5 16.61 157560 161936
64 513 502 2005 1960 1673 1612 170408 168440
128 535 526 2092 2054 3329 3344 195796 181524
256 571 571 2232 2233 6854 6873 246484 207856
We can see the benefit in memory consumption.
Change-Id: I40c70f6ccbad7754918bcc6cb397e955b09d1033
Signed-off-by: Evgeniy Kochetov <evgeniik@mellanox.com>
Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/428458
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-10-04 14:59:08 +00:00
|
|
|
* Copyright (c) Intel Corporation. All rights reserved.
|
2019-04-15 09:54:38 +00:00
|
|
|
* Copyright (c) 2018-2019 Mellanox Technologies LTD. All rights reserved.
|
2016-06-06 21:44:30 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2017-11-20 16:50:10 +00:00
|
|
|
#include "spdk/bdev.h"
|
2018-06-14 17:27:37 +00:00
|
|
|
#include "spdk/bit_array.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
#include "spdk/conf.h"
|
2018-06-11 20:32:15 +00:00
|
|
|
#include "spdk/thread.h"
|
2016-09-19 17:01:52 +00:00
|
|
|
#include "spdk/nvmf.h"
|
|
|
|
#include "spdk/trace.h"
|
2018-05-07 18:26:13 +00:00
|
|
|
#include "spdk/endian.h"
|
|
|
|
#include "spdk/string.h"
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2016-11-07 22:10:28 +00:00
|
|
|
#include "spdk_internal/log.h"
|
|
|
|
|
2017-08-29 20:22:37 +00:00
|
|
|
#include "nvmf_internal.h"
|
2016-07-14 22:25:23 +00:00
|
|
|
#include "transport.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2017-08-30 18:06:33 +00:00
|
|
|
SPDK_LOG_REGISTER_COMPONENT("nvmf", SPDK_LOG_NVMF)
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2018-05-08 23:05:28 +00:00
|
|
|
#define SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS 1024
|
2017-08-17 20:39:27 +00:00
|
|
|
|
2019-08-15 16:52:20 +00:00
|
|
|
static TAILQ_HEAD(, spdk_nvmf_tgt) g_nvmf_tgts = TAILQ_HEAD_INITIALIZER(g_nvmf_tgts);
|
|
|
|
|
2018-06-29 20:15:15 +00:00
|
|
|
typedef void (*nvmf_qpair_disconnect_cpl)(void *ctx, int status);
|
2018-08-28 22:41:16 +00:00
|
|
|
static void spdk_nvmf_tgt_destroy_poll_group(void *io_device, void *ctx_buf);
|
2018-06-29 20:15:15 +00:00
|
|
|
|
|
|
|
/* supplied to a single call to nvmf_qpair_disconnect */
|
2018-06-29 19:09:47 +00:00
|
|
|
struct nvmf_qpair_disconnect_ctx {
|
|
|
|
struct spdk_nvmf_qpair *qpair;
|
|
|
|
struct spdk_nvmf_ctrlr *ctrlr;
|
|
|
|
nvmf_qpair_disconnect_cb cb_fn;
|
2018-07-19 22:50:34 +00:00
|
|
|
struct spdk_thread *thread;
|
2018-06-29 19:09:47 +00:00
|
|
|
void *ctx;
|
2018-07-31 03:55:40 +00:00
|
|
|
uint16_t qid;
|
2018-06-29 19:09:47 +00:00
|
|
|
};
|
|
|
|
|
2018-06-29 20:15:15 +00:00
|
|
|
/*
|
|
|
|
* There are several times when we need to iterate through the list of all qpairs and selectively delete them.
|
|
|
|
* In order to do this sequentially without overlap, we must provide a context to recover the next qpair from
|
|
|
|
* to enable calling nvmf_qpair_disconnect on the next desired qpair.
|
|
|
|
*/
|
|
|
|
struct nvmf_qpair_disconnect_many_ctx {
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
struct spdk_nvmf_poll_group *group;
|
2018-07-13 23:23:23 +00:00
|
|
|
spdk_nvmf_poll_group_mod_done cpl_fn;
|
|
|
|
void *cpl_ctx;
|
2018-06-29 20:15:15 +00:00
|
|
|
};
|
|
|
|
|
2018-08-24 17:16:23 +00:00
|
|
|
static void
|
|
|
|
spdk_nvmf_qpair_set_state(struct spdk_nvmf_qpair *qpair,
|
|
|
|
enum spdk_nvmf_qpair_state state)
|
|
|
|
{
|
|
|
|
assert(qpair != NULL);
|
|
|
|
assert(qpair->group->thread == spdk_get_thread());
|
|
|
|
|
|
|
|
qpair->state = state;
|
|
|
|
}
|
|
|
|
|
2018-03-13 00:16:47 +00:00
|
|
|
static int
|
2017-11-17 17:01:39 +00:00
|
|
|
spdk_nvmf_poll_group_poll(void *ctx)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_poll_group *group = ctx;
|
|
|
|
int rc;
|
2018-03-13 00:16:47 +00:00
|
|
|
int count = 0;
|
2017-11-17 17:01:39 +00:00
|
|
|
struct spdk_nvmf_transport_poll_group *tgroup;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(tgroup, &group->tgroups, link) {
|
|
|
|
rc = spdk_nvmf_transport_poll_group_poll(tgroup);
|
|
|
|
if (rc < 0) {
|
2018-03-13 00:16:47 +00:00
|
|
|
return -1;
|
2017-11-17 17:01:39 +00:00
|
|
|
}
|
2018-03-13 00:16:47 +00:00
|
|
|
count += rc;
|
2017-11-17 17:01:39 +00:00
|
|
|
}
|
2018-03-13 00:16:47 +00:00
|
|
|
|
|
|
|
return count;
|
2017-11-17 17:01:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spdk_nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_tgt *tgt = io_device;
|
|
|
|
struct spdk_nvmf_poll_group *group = ctx_buf;
|
|
|
|
struct spdk_nvmf_transport *transport;
|
2017-11-20 16:50:10 +00:00
|
|
|
uint32_t sid;
|
2017-11-17 17:01:39 +00:00
|
|
|
|
|
|
|
TAILQ_INIT(&group->tgroups);
|
2018-06-01 22:10:12 +00:00
|
|
|
TAILQ_INIT(&group->qpairs);
|
2017-11-17 17:01:39 +00:00
|
|
|
|
|
|
|
TAILQ_FOREACH(transport, &tgt->transports, link) {
|
|
|
|
spdk_nvmf_poll_group_add_transport(group, transport);
|
|
|
|
}
|
|
|
|
|
2018-10-19 20:19:09 +00:00
|
|
|
group->num_sgroups = tgt->max_subsystems;
|
|
|
|
group->sgroups = calloc(tgt->max_subsystems, sizeof(struct spdk_nvmf_subsystem_poll_group));
|
2017-11-20 16:50:10 +00:00
|
|
|
if (!group->sgroups) {
|
2018-10-31 15:48:25 +00:00
|
|
|
return -ENOMEM;
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
|
2018-10-19 20:19:09 +00:00
|
|
|
for (sid = 0; sid < tgt->max_subsystems; sid++) {
|
2017-11-20 16:50:10 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
|
|
|
|
subsystem = tgt->subsystems[sid];
|
|
|
|
if (!subsystem) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-28 22:41:16 +00:00
|
|
|
if (spdk_nvmf_poll_group_add_subsystem(group, subsystem, NULL, NULL) != 0) {
|
|
|
|
spdk_nvmf_tgt_destroy_poll_group(io_device, ctx_buf);
|
|
|
|
return -1;
|
|
|
|
}
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 17:01:39 +00:00
|
|
|
group->poller = spdk_poller_register(spdk_nvmf_poll_group_poll, group, 0);
|
2018-02-08 03:54:59 +00:00
|
|
|
group->thread = spdk_get_thread();
|
2017-11-17 17:01:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-07-23 22:40:02 +00:00
|
|
|
spdk_nvmf_tgt_destroy_poll_group(void *io_device, void *ctx_buf)
|
2017-11-17 17:01:39 +00:00
|
|
|
{
|
2018-07-23 22:40:02 +00:00
|
|
|
struct spdk_nvmf_poll_group *group = ctx_buf;
|
2017-11-17 17:01:39 +00:00
|
|
|
struct spdk_nvmf_transport_poll_group *tgroup, *tmp;
|
2017-11-20 16:50:10 +00:00
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
|
|
|
uint32_t sid, nsid;
|
2017-11-17 17:01:39 +00:00
|
|
|
|
|
|
|
TAILQ_FOREACH_SAFE(tgroup, &group->tgroups, link, tmp) {
|
|
|
|
TAILQ_REMOVE(&group->tgroups, tgroup, link);
|
|
|
|
spdk_nvmf_transport_poll_group_destroy(tgroup);
|
|
|
|
}
|
2017-11-20 16:50:10 +00:00
|
|
|
|
|
|
|
for (sid = 0; sid < group->num_sgroups; sid++) {
|
|
|
|
sgroup = &group->sgroups[sid];
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
for (nsid = 0; nsid < sgroup->num_ns; nsid++) {
|
|
|
|
if (sgroup->ns_info[nsid].channel) {
|
|
|
|
spdk_put_io_channel(sgroup->ns_info[nsid].channel);
|
|
|
|
sgroup->ns_info[nsid].channel = NULL;
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
free(sgroup->ns_info);
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(group->sgroups);
|
2017-11-17 17:01:39 +00:00
|
|
|
}
|
|
|
|
|
2018-06-29 23:19:45 +00:00
|
|
|
static void
|
|
|
|
_nvmf_tgt_disconnect_next_qpair(void *ctx)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_qpair *qpair;
|
|
|
|
struct nvmf_qpair_disconnect_many_ctx *qpair_ctx = ctx;
|
|
|
|
struct spdk_nvmf_poll_group *group = qpair_ctx->group;
|
2018-07-23 22:40:02 +00:00
|
|
|
struct spdk_io_channel *ch;
|
2018-06-29 23:19:45 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
qpair = TAILQ_FIRST(&group->qpairs);
|
|
|
|
|
|
|
|
if (qpair) {
|
|
|
|
rc = spdk_nvmf_qpair_disconnect(qpair, _nvmf_tgt_disconnect_next_qpair, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!qpair || rc != 0) {
|
2018-07-23 22:40:02 +00:00
|
|
|
/* When the refcount from the channels reaches 0, spdk_nvmf_tgt_destroy_poll_group will be called. */
|
|
|
|
ch = spdk_io_channel_from_ctx(group);
|
|
|
|
spdk_put_io_channel(ch);
|
2018-06-29 23:19:45 +00:00
|
|
|
free(qpair_ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-07-23 22:40:02 +00:00
|
|
|
spdk_nvmf_tgt_destroy_poll_group_qpairs(struct spdk_nvmf_poll_group *group)
|
2018-06-29 23:19:45 +00:00
|
|
|
{
|
|
|
|
struct nvmf_qpair_disconnect_many_ctx *ctx;
|
|
|
|
|
|
|
|
ctx = calloc(1, sizeof(struct nvmf_qpair_disconnect_many_ctx));
|
|
|
|
|
|
|
|
if (!ctx) {
|
|
|
|
SPDK_ERRLOG("Failed to allocate memory for destroy poll group ctx\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spdk_poller_unregister(&group->poller);
|
|
|
|
|
|
|
|
ctx->group = group;
|
2018-07-23 22:40:02 +00:00
|
|
|
_nvmf_tgt_disconnect_next_qpair(ctx);
|
2018-06-29 23:19:45 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 22:38:33 +00:00
|
|
|
struct spdk_nvmf_tgt *
|
2019-08-15 20:51:08 +00:00
|
|
|
spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts)
|
2016-06-06 21:44:30 +00:00
|
|
|
{
|
2019-08-15 17:34:12 +00:00
|
|
|
struct spdk_nvmf_tgt *tgt, *tmp_tgt;
|
|
|
|
|
|
|
|
if (strnlen(opts->name, NVMF_TGT_NAME_MAX_LENGTH) == NVMF_TGT_NAME_MAX_LENGTH) {
|
|
|
|
SPDK_ERRLOG("Provided target name exceeds the max length of %u.\n", NVMF_TGT_NAME_MAX_LENGTH);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TAILQ_FOREACH(tmp_tgt, &g_nvmf_tgts, link) {
|
2019-09-16 21:26:29 +00:00
|
|
|
if (!strncmp(opts->name, tmp_tgt->name, NVMF_TGT_NAME_MAX_LENGTH)) {
|
2019-08-15 17:34:12 +00:00
|
|
|
SPDK_ERRLOG("Provided target name must be unique.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2017-08-18 22:38:33 +00:00
|
|
|
|
2017-08-23 17:35:44 +00:00
|
|
|
tgt = calloc(1, sizeof(*tgt));
|
|
|
|
if (!tgt) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-08-18 22:38:33 +00:00
|
|
|
|
2019-08-15 17:34:12 +00:00
|
|
|
snprintf(tgt->name, NVMF_TGT_NAME_MAX_LENGTH, "%s", opts->name);
|
|
|
|
|
2019-08-15 20:51:08 +00:00
|
|
|
if (!opts || !opts->max_subsystems) {
|
2018-10-19 20:19:09 +00:00
|
|
|
tgt->max_subsystems = SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS;
|
2017-08-17 20:39:27 +00:00
|
|
|
} else {
|
2019-08-15 20:51:08 +00:00
|
|
|
tgt->max_subsystems = opts->max_subsystems;
|
2017-08-17 20:39:27 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 22:38:33 +00:00
|
|
|
tgt->discovery_genctr = 0;
|
|
|
|
TAILQ_INIT(&tgt->transports);
|
2016-07-25 21:22:58 +00:00
|
|
|
|
2018-10-19 20:19:09 +00:00
|
|
|
tgt->subsystems = calloc(tgt->max_subsystems, sizeof(struct spdk_nvmf_subsystem *));
|
2018-05-08 23:05:28 +00:00
|
|
|
if (!tgt->subsystems) {
|
|
|
|
free(tgt);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-08-15 16:52:20 +00:00
|
|
|
TAILQ_INSERT_HEAD(&g_nvmf_tgts, tgt, link);
|
|
|
|
|
2017-11-17 17:01:39 +00:00
|
|
|
spdk_io_device_register(tgt,
|
|
|
|
spdk_nvmf_tgt_create_poll_group,
|
|
|
|
spdk_nvmf_tgt_destroy_poll_group,
|
2018-08-30 20:26:50 +00:00
|
|
|
sizeof(struct spdk_nvmf_poll_group),
|
2019-08-15 17:34:12 +00:00
|
|
|
tgt->name);
|
2017-11-17 17:01:39 +00:00
|
|
|
|
2017-08-18 22:38:33 +00:00
|
|
|
return tgt;
|
2016-06-06 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
2018-06-05 22:34:04 +00:00
|
|
|
static void
|
|
|
|
spdk_nvmf_tgt_destroy_cb(void *io_device)
|
2016-10-19 17:03:45 +00:00
|
|
|
{
|
2018-06-05 22:34:04 +00:00
|
|
|
struct spdk_nvmf_tgt *tgt = io_device;
|
2017-07-24 23:30:07 +00:00
|
|
|
struct spdk_nvmf_transport *transport, *transport_tmp;
|
2018-06-05 22:34:04 +00:00
|
|
|
spdk_nvmf_tgt_destroy_done_fn *destroy_cb_fn;
|
|
|
|
void *destroy_cb_arg;
|
2017-12-20 20:45:59 +00:00
|
|
|
uint32_t i;
|
2017-02-20 04:49:39 +00:00
|
|
|
|
2017-08-29 20:03:13 +00:00
|
|
|
if (tgt->subsystems) {
|
2018-10-19 20:19:09 +00:00
|
|
|
for (i = 0; i < tgt->max_subsystems; i++) {
|
2017-12-20 20:45:59 +00:00
|
|
|
if (tgt->subsystems[i]) {
|
2017-12-19 23:39:04 +00:00
|
|
|
spdk_nvmf_subsystem_destroy(tgt->subsystems[i]);
|
2017-12-20 20:45:59 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-29 20:03:13 +00:00
|
|
|
free(tgt->subsystems);
|
|
|
|
}
|
|
|
|
|
2018-02-12 08:58:31 +00:00
|
|
|
TAILQ_FOREACH_SAFE(transport, &tgt->transports, link, transport_tmp) {
|
|
|
|
TAILQ_REMOVE(&tgt->transports, transport, link);
|
|
|
|
spdk_nvmf_transport_destroy(transport);
|
|
|
|
}
|
|
|
|
|
2018-06-05 22:34:04 +00:00
|
|
|
destroy_cb_fn = tgt->destroy_cb_fn;
|
|
|
|
destroy_cb_arg = tgt->destroy_cb_arg;
|
|
|
|
|
2017-08-23 17:35:44 +00:00
|
|
|
free(tgt);
|
2018-06-05 22:34:04 +00:00
|
|
|
|
|
|
|
if (destroy_cb_fn) {
|
|
|
|
destroy_cb_fn(destroy_cb_arg, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_nvmf_tgt_destroy(struct spdk_nvmf_tgt *tgt,
|
|
|
|
spdk_nvmf_tgt_destroy_done_fn cb_fn,
|
|
|
|
void *cb_arg)
|
|
|
|
{
|
|
|
|
tgt->destroy_cb_fn = cb_fn;
|
|
|
|
tgt->destroy_cb_arg = cb_arg;
|
|
|
|
|
2019-08-15 16:52:20 +00:00
|
|
|
TAILQ_REMOVE(&g_nvmf_tgts, tgt, link);
|
|
|
|
|
2018-06-05 22:34:04 +00:00
|
|
|
spdk_io_device_unregister(tgt, spdk_nvmf_tgt_destroy_cb);
|
2016-10-19 17:03:45 +00:00
|
|
|
}
|
|
|
|
|
2019-09-13 18:09:07 +00:00
|
|
|
const char *
|
|
|
|
spdk_nvmf_tgt_get_name(struct spdk_nvmf_tgt *tgt)
|
|
|
|
{
|
|
|
|
return tgt->name;
|
|
|
|
}
|
|
|
|
|
2019-08-15 18:32:11 +00:00
|
|
|
struct spdk_nvmf_tgt *
|
|
|
|
spdk_nvmf_get_tgt(const char *name)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_tgt *tgt;
|
|
|
|
uint32_t num_targets = 0;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(tgt, &g_nvmf_tgts, link) {
|
|
|
|
if (name) {
|
2019-09-16 21:26:29 +00:00
|
|
|
if (!strncmp(tgt->name, name, NVMF_TGT_NAME_MAX_LENGTH)) {
|
2019-08-15 18:32:11 +00:00
|
|
|
return tgt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
num_targets++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* special case. If there is only one target and
|
|
|
|
* no name was specified, return the only available
|
|
|
|
* target. If there is more than one target, name must
|
|
|
|
* be specified.
|
|
|
|
*/
|
|
|
|
if (!name && num_targets == 1) {
|
|
|
|
return TAILQ_FIRST(&g_nvmf_tgts);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:09:07 +00:00
|
|
|
struct spdk_nvmf_tgt *
|
|
|
|
spdk_nvmf_get_first_tgt(void)
|
|
|
|
{
|
|
|
|
return TAILQ_FIRST(&g_nvmf_tgts);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct spdk_nvmf_tgt *
|
|
|
|
spdk_nvmf_get_next_tgt(struct spdk_nvmf_tgt *prev)
|
|
|
|
{
|
|
|
|
return TAILQ_NEXT(prev, link);
|
|
|
|
}
|
|
|
|
|
2018-05-07 18:26:13 +00:00
|
|
|
static void
|
|
|
|
spdk_nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_host *host;
|
|
|
|
struct spdk_nvmf_listener *listener;
|
|
|
|
const struct spdk_nvme_transport_id *trid;
|
|
|
|
struct spdk_nvmf_ns *ns;
|
|
|
|
struct spdk_nvmf_ns_opts ns_opts;
|
|
|
|
uint32_t max_namespaces;
|
|
|
|
char uuid_str[SPDK_UUID_STRING_LEN];
|
|
|
|
const char *trtype;
|
|
|
|
const char *adrfam;
|
|
|
|
|
|
|
|
if (spdk_nvmf_subsystem_get_type(subsystem) != SPDK_NVMF_SUBTYPE_NVME) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* { */
|
|
|
|
spdk_json_write_object_begin(w);
|
2019-09-20 10:22:44 +00:00
|
|
|
spdk_json_write_named_string(w, "method", "nvmf_create_subsystem");
|
2018-05-07 18:26:13 +00:00
|
|
|
|
|
|
|
/* "params" : { */
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
|
|
|
spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem));
|
|
|
|
spdk_json_write_named_bool(w, "allow_any_host", spdk_nvmf_subsystem_get_allow_any_host(subsystem));
|
2018-09-10 18:27:39 +00:00
|
|
|
spdk_json_write_named_string(w, "serial_number", spdk_nvmf_subsystem_get_sn(subsystem));
|
2018-12-29 19:39:48 +00:00
|
|
|
spdk_json_write_named_string(w, "model_number", spdk_nvmf_subsystem_get_mn(subsystem));
|
2018-09-10 18:27:39 +00:00
|
|
|
|
|
|
|
max_namespaces = spdk_nvmf_subsystem_get_max_namespaces(subsystem);
|
|
|
|
if (max_namespaces != 0) {
|
|
|
|
spdk_json_write_named_uint32(w, "max_namespaces", max_namespaces);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* } "params" */
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
|
|
|
/* } */
|
|
|
|
spdk_json_write_object_end(w);
|
2018-05-07 18:26:13 +00:00
|
|
|
|
|
|
|
for (listener = spdk_nvmf_subsystem_get_first_listener(subsystem); listener != NULL;
|
|
|
|
listener = spdk_nvmf_subsystem_get_next_listener(subsystem, listener)) {
|
|
|
|
trid = spdk_nvmf_listener_get_trid(listener);
|
|
|
|
|
|
|
|
trtype = spdk_nvme_transport_id_trtype_str(trid->trtype);
|
|
|
|
adrfam = spdk_nvme_transport_id_adrfam_str(trid->adrfam);
|
|
|
|
|
|
|
|
spdk_json_write_object_begin(w);
|
2018-09-10 18:27:39 +00:00
|
|
|
spdk_json_write_named_string(w, "method", "nvmf_subsystem_add_listener");
|
|
|
|
|
|
|
|
/* "params" : { */
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
|
|
|
|
|
|
|
spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem));
|
|
|
|
|
|
|
|
/* "listen_address" : { */
|
|
|
|
spdk_json_write_named_object_begin(w, "listen_address");
|
|
|
|
|
2018-05-07 18:26:13 +00:00
|
|
|
spdk_json_write_named_string(w, "trtype", trtype);
|
|
|
|
if (adrfam) {
|
|
|
|
spdk_json_write_named_string(w, "adrfam", adrfam);
|
|
|
|
}
|
|
|
|
|
|
|
|
spdk_json_write_named_string(w, "traddr", trid->traddr);
|
|
|
|
spdk_json_write_named_string(w, "trsvcid", trid->trsvcid);
|
2018-09-10 18:27:39 +00:00
|
|
|
/* } "listen_address" */
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
|
|
|
/* } "params" */
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
|
|
|
/* } */
|
2018-05-07 18:26:13 +00:00
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (host = spdk_nvmf_subsystem_get_first_host(subsystem); host != NULL;
|
|
|
|
host = spdk_nvmf_subsystem_get_next_host(subsystem, host)) {
|
|
|
|
|
2018-09-10 18:27:39 +00:00
|
|
|
spdk_json_write_object_begin(w);
|
|
|
|
spdk_json_write_named_string(w, "method", "nvmf_subsystem_add_host");
|
2018-05-07 18:26:13 +00:00
|
|
|
|
2018-09-10 18:27:39 +00:00
|
|
|
/* "params" : { */
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
|
|
|
|
|
|
|
spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem));
|
|
|
|
spdk_json_write_named_string(w, "host", spdk_nvmf_host_get_nqn(host));
|
|
|
|
|
|
|
|
/* } "params" */
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
|
|
|
/* } */
|
|
|
|
spdk_json_write_object_end(w);
|
2018-05-07 18:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (ns = spdk_nvmf_subsystem_get_first_ns(subsystem); ns != NULL;
|
|
|
|
ns = spdk_nvmf_subsystem_get_next_ns(subsystem, ns)) {
|
|
|
|
spdk_nvmf_ns_get_opts(ns, &ns_opts, sizeof(ns_opts));
|
|
|
|
|
|
|
|
spdk_json_write_object_begin(w);
|
2018-09-10 18:27:39 +00:00
|
|
|
spdk_json_write_named_string(w, "method", "nvmf_subsystem_add_ns");
|
|
|
|
|
|
|
|
/* "params" : { */
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
|
|
|
|
|
|
|
spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem));
|
|
|
|
|
|
|
|
/* "namespace" : { */
|
|
|
|
spdk_json_write_named_object_begin(w, "namespace");
|
|
|
|
|
2018-05-07 18:26:13 +00:00
|
|
|
spdk_json_write_named_uint32(w, "nsid", spdk_nvmf_ns_get_id(ns));
|
|
|
|
spdk_json_write_named_string(w, "bdev_name", spdk_bdev_get_name(spdk_nvmf_ns_get_bdev(ns)));
|
|
|
|
|
|
|
|
if (!spdk_mem_all_zero(ns_opts.nguid, sizeof(ns_opts.nguid))) {
|
|
|
|
SPDK_STATIC_ASSERT(sizeof(ns_opts.nguid) == sizeof(uint64_t) * 2, "size mismatch");
|
|
|
|
spdk_json_write_named_string_fmt(w, "nguid", "%016"PRIX64"%016"PRIX64, from_be64(&ns_opts.nguid[0]),
|
|
|
|
from_be64(&ns_opts.nguid[8]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!spdk_mem_all_zero(ns_opts.eui64, sizeof(ns_opts.eui64))) {
|
|
|
|
SPDK_STATIC_ASSERT(sizeof(ns_opts.eui64) == sizeof(uint64_t), "size mismatch");
|
|
|
|
spdk_json_write_named_string_fmt(w, "eui64", "%016"PRIX64, from_be64(&ns_opts.eui64));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!spdk_mem_all_zero(&ns_opts.uuid, sizeof(ns_opts.uuid))) {
|
|
|
|
spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &ns_opts.uuid);
|
|
|
|
spdk_json_write_named_string(w, "uuid", uuid_str);
|
|
|
|
}
|
|
|
|
|
2018-09-10 18:27:39 +00:00
|
|
|
/* "namespace" */
|
|
|
|
spdk_json_write_object_end(w);
|
2018-05-07 18:26:13 +00:00
|
|
|
|
2018-09-10 18:27:39 +00:00
|
|
|
/* } "params" */
|
|
|
|
spdk_json_write_object_end(w);
|
2018-05-07 18:26:13 +00:00
|
|
|
|
2018-09-10 18:27:39 +00:00
|
|
|
/* } */
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
}
|
2018-05-07 18:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_nvmf_tgt_write_config_json(struct spdk_json_write_ctx *w, struct spdk_nvmf_tgt *tgt)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
2018-08-27 22:27:47 +00:00
|
|
|
struct spdk_nvmf_transport *transport;
|
2018-05-07 18:26:13 +00:00
|
|
|
|
|
|
|
spdk_json_write_object_begin(w);
|
2019-09-23 10:29:33 +00:00
|
|
|
spdk_json_write_named_string(w, "method", "nvmf_set_max_subsystems");
|
2018-05-07 18:26:13 +00:00
|
|
|
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
2018-10-19 20:19:09 +00:00
|
|
|
spdk_json_write_named_uint32(w, "max_subsystems", tgt->max_subsystems);
|
2018-05-07 18:26:13 +00:00
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
/* write transports */
|
|
|
|
TAILQ_FOREACH(transport, &tgt->transports, link) {
|
|
|
|
spdk_json_write_object_begin(w);
|
|
|
|
spdk_json_write_named_string(w, "method", "nvmf_create_transport");
|
|
|
|
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
|
|
|
spdk_json_write_named_string(w, "trtype", spdk_nvme_transport_id_trtype_str(transport->ops->type));
|
|
|
|
spdk_json_write_named_uint32(w, "max_queue_depth", transport->opts.max_queue_depth);
|
|
|
|
spdk_json_write_named_uint32(w, "max_qpairs_per_ctrlr", transport->opts.max_qpairs_per_ctrlr);
|
|
|
|
spdk_json_write_named_uint32(w, "in_capsule_data_size", transport->opts.in_capsule_data_size);
|
|
|
|
spdk_json_write_named_uint32(w, "max_io_size", transport->opts.max_io_size);
|
|
|
|
spdk_json_write_named_uint32(w, "io_unit_size", transport->opts.io_unit_size);
|
|
|
|
spdk_json_write_named_uint32(w, "max_aq_depth", transport->opts.max_aq_depth);
|
nvmf/rdma: Add shared receive queue support
This is a new feature for NVMEoF RDMA target, that is intended to save
resource allocation (by sharing them) and utilize the
locality (completions and memory) to get the best performance with
Shared Receive Queues (SRQs). We'll create a SRQ per core (poll
group), per device and associate each created QP/CQ with an
appropriate SRQ.
Our testing environment has 2 hosts.
Host 1:
CPU: Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz dual socket (8 cores total)
Network: ConnectX-5, ConnectX-5 VPI , 100GbE, single-port QSFP28, PCIe3.0 x16
Disk: Intel Optane SSD 900P Series
OS: Fedora 27 x86_64
Host 2:
CPU: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz dual-socket (24 cores total)
Network: ConnectX-4 VPI , 100GbE, dual-port QSFP28
Disk: Intel Optane SSD 900P Series
OS : CentOS 7.5.1804 x86_64
Hosts are connected via Spectrum switch.
Host 1 is running SPDK NVMeoF target.
Host 2 is used as initiator running fio with SPDK plugin.
Configuration:
- SPDK NVMeoF target: cpu mask 0x0F (4 cores), max queue depth 128,
max SRQ depth 1024, max QPs per controller 1024
- Single NVMf subsystem with single namespace backed by physical SSD disk
- fio with SPDK plugin: randread pattern, 1-256 jobs, block size 4k,
IO depth 16, cpu_mask 0xFFF0, IO rate 10k, rate process “poisson”
Here is a full fio command line:
fio --name=Job --stats=1 --group_reporting=1 --idle-prof=percpu \
--loops=1 --numjobs=1 --thread=1 --time_based=1 --runtime=30s \
--ramp_time=5s --bs=4k --size=4G --iodepth=16 --readwrite=randread \
--rwmixread=75 --randrepeat=1 --ioengine=spdk --direct=1 \
--gtod_reduce=0 --cpumask=0xFFF0 --rate_iops=10k \
--rate_process=poisson \
--filename='trtype=RDMA adrfam=IPv4 traddr=1.1.79.1 trsvcid=4420 ns=1'
SPDK allocates the following entities for every work request in
receive queue (shared or not): reqs (1024 bytes), recvs (96 bytes),
cmds (64 bytes), cpls (16 bytes), in_capsule_buffer. All except the
last one are fixed size. In capsule data size is configured to 4096.
Memory consumption calculation (target):
- Multiple SRQ: core_num * ib_devs_num * SRQ_depth * (1200 +
in_capsule_data_size)
- Multiple RQ: queue_num * RQ_depth * (1200 + in_capsule_data_size)
We ignore admin queues in calculations for simplicity.
Cases:
1. Multiple SRQ with 1024 entries:
- Mem = 4 * 1 * 1024 * (1200 + 4096) = 20.7 MiB
(Constant number – does not depend on initiators number)
2. RQ with 128 entries for 64 initiators:
- Mem = 64 * 128 * (1200 + 4096) = 41.4 MiB
Results:
FIO_JOBS kIOPS Bandwidth,MiB/s AvgLatency,us MaxResidentSize,kiB
RQ SRQ RQ SRQ RQ SRQ RQ SRQ
1 8.623 8.623 33.7 33.7 13.89 14.03 144376 155624
2 17.3 17.3 67.4 67.4 14.03 14.1 145776 155700
4 34.5 34.5 135 135 14.15 14.23 146540 156184
8 69.1 69.1 270 270 14.64 14.49 148116 156960
16 138 138 540 540 14.84 15.38 151216 158668
32 276 276 1079 1079 16.5 16.61 157560 161936
64 513 502 2005 1960 1673 1612 170408 168440
128 535 526 2092 2054 3329 3344 195796 181524
256 571 571 2232 2233 6854 6873 246484 207856
We can see the benefit in memory consumption.
Change-Id: I40c70f6ccbad7754918bcc6cb397e955b09d1033
Signed-off-by: Evgeniy Kochetov <evgeniik@mellanox.com>
Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/428458
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-10-04 14:59:08 +00:00
|
|
|
if (transport->ops->type == SPDK_NVME_TRANSPORT_RDMA) {
|
|
|
|
spdk_json_write_named_uint32(w, "max_srq_depth", transport->opts.max_srq_depth);
|
|
|
|
}
|
2018-08-27 22:27:47 +00:00
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
}
|
|
|
|
|
2018-05-07 18:26:13 +00:00
|
|
|
subsystem = spdk_nvmf_subsystem_get_first(tgt);
|
|
|
|
while (subsystem) {
|
|
|
|
spdk_nvmf_write_subsystem_config_json(w, subsystem);
|
|
|
|
subsystem = spdk_nvmf_subsystem_get_next(subsystem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-03 18:35:04 +00:00
|
|
|
void
|
2017-08-21 18:41:51 +00:00
|
|
|
spdk_nvmf_tgt_listen(struct spdk_nvmf_tgt *tgt,
|
2018-04-03 18:35:04 +00:00
|
|
|
struct spdk_nvme_transport_id *trid,
|
|
|
|
spdk_nvmf_tgt_listen_done_fn cb_fn,
|
|
|
|
void *cb_arg)
|
2017-08-21 18:41:51 +00:00
|
|
|
{
|
|
|
|
struct spdk_nvmf_transport *transport;
|
2018-10-19 17:21:06 +00:00
|
|
|
const char *trtype;
|
2017-08-21 18:41:51 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
transport = spdk_nvmf_tgt_get_transport(tgt, trid->trtype);
|
|
|
|
if (!transport) {
|
2018-10-19 17:21:06 +00:00
|
|
|
trtype = spdk_nvme_transport_id_trtype_str(trid->trtype);
|
|
|
|
if (trtype != NULL) {
|
|
|
|
SPDK_ERRLOG("Unable to listen on transport %s. The transport must be created first.\n", trtype);
|
|
|
|
} else {
|
|
|
|
SPDK_ERRLOG("The specified trtype %d is unknown. Please make sure that it is properly registered.\n",
|
|
|
|
trid->trtype);
|
2017-08-21 18:41:51 +00:00
|
|
|
}
|
2018-10-19 17:21:06 +00:00
|
|
|
cb_fn(cb_arg, -EINVAL);
|
|
|
|
return;
|
2018-04-03 18:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = spdk_nvmf_transport_listen(transport, trid);
|
|
|
|
if (rc < 0) {
|
|
|
|
SPDK_ERRLOG("Unable to listen on address '%s'\n", trid->traddr);
|
|
|
|
cb_fn(cb_arg, rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tgt->discovery_genctr++;
|
|
|
|
|
2018-10-19 17:21:06 +00:00
|
|
|
cb_fn(cb_arg, 0);
|
2018-08-27 22:27:47 +00:00
|
|
|
}
|
2018-04-03 18:35:04 +00:00
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
struct spdk_nvmf_tgt_add_transport_ctx {
|
|
|
|
struct spdk_nvmf_tgt *tgt;
|
|
|
|
struct spdk_nvmf_transport *transport;
|
|
|
|
spdk_nvmf_tgt_add_transport_done_fn cb_fn;
|
|
|
|
void *cb_arg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_spdk_nvmf_tgt_add_transport_done(struct spdk_io_channel_iter *i, int status)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_tgt_add_transport_ctx *ctx = spdk_io_channel_iter_get_ctx(i);
|
2017-11-17 17:01:39 +00:00
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
ctx->cb_fn(ctx->cb_arg, status);
|
2017-11-17 17:01:39 +00:00
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
free(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_spdk_nvmf_tgt_add_transport(struct spdk_io_channel_iter *i)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_tgt_add_transport_ctx *ctx = spdk_io_channel_iter_get_ctx(i);
|
|
|
|
struct spdk_io_channel *ch = spdk_io_channel_iter_get_channel(i);
|
|
|
|
struct spdk_nvmf_poll_group *group = spdk_io_channel_get_ctx(ch);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = spdk_nvmf_poll_group_add_transport(group, ctx->transport);
|
|
|
|
spdk_for_each_channel_continue(i, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void spdk_nvmf_tgt_add_transport(struct spdk_nvmf_tgt *tgt,
|
|
|
|
struct spdk_nvmf_transport *transport,
|
|
|
|
spdk_nvmf_tgt_add_transport_done_fn cb_fn,
|
|
|
|
void *cb_arg)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_tgt_add_transport_ctx *ctx;
|
|
|
|
|
|
|
|
if (spdk_nvmf_tgt_get_transport(tgt, transport->ops->type)) {
|
|
|
|
cb_fn(cb_arg, -EEXIST);
|
|
|
|
return; /* transport already created */
|
2017-11-17 17:01:39 +00:00
|
|
|
}
|
2018-08-27 22:27:47 +00:00
|
|
|
|
|
|
|
transport->tgt = tgt;
|
|
|
|
TAILQ_INSERT_TAIL(&tgt->transports, transport, link);
|
|
|
|
|
|
|
|
ctx = calloc(1, sizeof(*ctx));
|
|
|
|
if (!ctx) {
|
|
|
|
cb_fn(cb_arg, -ENOMEM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->tgt = tgt;
|
|
|
|
ctx->transport = transport;
|
|
|
|
ctx->cb_fn = cb_fn;
|
|
|
|
ctx->cb_arg = cb_arg;
|
|
|
|
|
|
|
|
spdk_for_each_channel(tgt,
|
|
|
|
_spdk_nvmf_tgt_add_transport,
|
|
|
|
ctx,
|
|
|
|
_spdk_nvmf_tgt_add_transport_done);
|
2017-08-21 18:41:51 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 23:05:13 +00:00
|
|
|
struct spdk_nvmf_subsystem *
|
|
|
|
spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
2017-08-29 20:03:13 +00:00
|
|
|
uint32_t sid;
|
2017-08-18 23:05:13 +00:00
|
|
|
|
|
|
|
if (!subnqn) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-10-19 20:19:09 +00:00
|
|
|
for (sid = 0; sid < tgt->max_subsystems; sid++) {
|
2017-08-29 20:03:13 +00:00
|
|
|
subsystem = tgt->subsystems[sid];
|
|
|
|
if (subsystem == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-08-18 23:05:13 +00:00
|
|
|
if (strcmp(subnqn, subsystem->subnqn) == 0) {
|
|
|
|
return subsystem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-07-24 23:30:07 +00:00
|
|
|
struct spdk_nvmf_transport *
|
|
|
|
spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt, enum spdk_nvme_transport_type type)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_transport *transport;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(transport, &tgt->transports, link) {
|
|
|
|
if (transport->ops->type == type) {
|
|
|
|
return transport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-09-18 20:16:15 +00:00
|
|
|
spdk_nvmf_tgt_accept(struct spdk_nvmf_tgt *tgt, new_qpair_fn cb_fn, void *cb_arg)
|
2017-07-24 23:30:07 +00:00
|
|
|
{
|
|
|
|
struct spdk_nvmf_transport *transport, *tmp;
|
|
|
|
|
2017-08-21 21:07:44 +00:00
|
|
|
TAILQ_FOREACH_SAFE(transport, &tgt->transports, link, tmp) {
|
2019-09-18 20:16:15 +00:00
|
|
|
spdk_nvmf_transport_accept(transport, cb_fn, cb_arg);
|
2017-07-24 23:30:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-28 23:24:33 +00:00
|
|
|
struct spdk_nvmf_poll_group *
|
|
|
|
spdk_nvmf_poll_group_create(struct spdk_nvmf_tgt *tgt)
|
|
|
|
{
|
2017-11-17 17:01:39 +00:00
|
|
|
struct spdk_io_channel *ch;
|
2017-08-28 23:24:33 +00:00
|
|
|
|
2017-11-17 17:01:39 +00:00
|
|
|
ch = spdk_get_io_channel(tgt);
|
|
|
|
if (!ch) {
|
|
|
|
SPDK_ERRLOG("Unable to get I/O channel for target\n");
|
2017-08-28 23:24:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-11-17 17:01:39 +00:00
|
|
|
return spdk_io_channel_get_ctx(ch);
|
2017-08-28 23:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_nvmf_poll_group_destroy(struct spdk_nvmf_poll_group *group)
|
|
|
|
{
|
2018-07-23 22:40:02 +00:00
|
|
|
/* This function will put the io_channel associated with this poll group */
|
|
|
|
spdk_nvmf_tgt_destroy_poll_group_qpairs(group);
|
2017-08-28 23:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
spdk_nvmf_poll_group_add(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_qpair *qpair)
|
|
|
|
{
|
|
|
|
int rc = -1;
|
|
|
|
struct spdk_nvmf_transport_poll_group *tgroup;
|
|
|
|
|
2018-05-11 00:18:40 +00:00
|
|
|
TAILQ_INIT(&qpair->outstanding);
|
2017-11-29 20:59:10 +00:00
|
|
|
qpair->group = group;
|
|
|
|
|
2017-08-28 23:24:33 +00:00
|
|
|
TAILQ_FOREACH(tgroup, &group->tgroups, link) {
|
|
|
|
if (tgroup->transport == qpair->transport) {
|
|
|
|
rc = spdk_nvmf_transport_poll_group_add(tgroup, qpair);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-17 18:40:31 +00:00
|
|
|
/* We add the qpair to the group only it is succesfully added into the tgroup */
|
2018-05-22 17:07:43 +00:00
|
|
|
if (rc == 0) {
|
2018-12-17 18:40:31 +00:00
|
|
|
TAILQ_INSERT_TAIL(&group->qpairs, qpair, link);
|
2018-08-24 17:16:23 +00:00
|
|
|
spdk_nvmf_qpair_set_state(qpair, SPDK_NVMF_QPAIR_ACTIVE);
|
2018-05-22 17:07:43 +00:00
|
|
|
}
|
|
|
|
|
2017-08-28 23:24:33 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2018-07-31 03:55:40 +00:00
|
|
|
static
|
|
|
|
void _nvmf_ctrlr_destruct(void *ctx)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_ctrlr *ctrlr = ctx;
|
|
|
|
|
|
|
|
spdk_nvmf_ctrlr_destruct(ctrlr);
|
|
|
|
}
|
|
|
|
|
2018-06-14 17:27:37 +00:00
|
|
|
static void
|
2018-06-29 19:09:47 +00:00
|
|
|
_spdk_nvmf_ctrlr_free_from_qpair(void *ctx)
|
2018-06-14 17:27:37 +00:00
|
|
|
{
|
2018-06-29 19:09:47 +00:00
|
|
|
struct nvmf_qpair_disconnect_ctx *qpair_ctx = ctx;
|
|
|
|
struct spdk_nvmf_ctrlr *ctrlr = qpair_ctx->ctrlr;
|
2018-07-31 03:55:40 +00:00
|
|
|
uint32_t count;
|
2018-06-14 17:27:37 +00:00
|
|
|
|
2018-07-31 03:55:40 +00:00
|
|
|
spdk_bit_array_clear(ctrlr->qpair_mask, qpair_ctx->qid);
|
|
|
|
count = spdk_bit_array_count_set(ctrlr->qpair_mask);
|
|
|
|
if (count == 0) {
|
|
|
|
spdk_bit_array_free(&ctrlr->qpair_mask);
|
|
|
|
|
|
|
|
spdk_thread_send_msg(ctrlr->subsys->thread, _nvmf_ctrlr_destruct, ctrlr);
|
|
|
|
}
|
2018-06-29 19:09:47 +00:00
|
|
|
|
|
|
|
if (qpair_ctx->cb_fn) {
|
2018-07-19 22:50:34 +00:00
|
|
|
spdk_thread_send_msg(qpair_ctx->thread, qpair_ctx->cb_fn, qpair_ctx->ctx);
|
2018-06-29 19:09:47 +00:00
|
|
|
}
|
|
|
|
free(qpair_ctx);
|
2018-06-14 17:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-06-01 22:10:12 +00:00
|
|
|
_spdk_nvmf_qpair_destroy(void *ctx, int status)
|
2018-06-14 17:27:37 +00:00
|
|
|
{
|
2018-06-29 19:09:47 +00:00
|
|
|
struct nvmf_qpair_disconnect_ctx *qpair_ctx = ctx;
|
|
|
|
struct spdk_nvmf_qpair *qpair = qpair_ctx->qpair;
|
2018-06-01 22:10:12 +00:00
|
|
|
struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr;
|
2018-11-21 02:11:25 +00:00
|
|
|
struct spdk_nvmf_transport_poll_group *tgroup;
|
2019-01-22 22:47:55 +00:00
|
|
|
struct spdk_nvmf_request *req, *tmp;
|
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
2018-11-21 02:11:25 +00:00
|
|
|
int rc;
|
2018-08-02 22:27:32 +00:00
|
|
|
|
2018-06-14 17:27:37 +00:00
|
|
|
assert(qpair->state == SPDK_NVMF_QPAIR_DEACTIVATING);
|
2018-10-24 19:12:23 +00:00
|
|
|
spdk_nvmf_qpair_set_state(qpair, SPDK_NVMF_QPAIR_ERROR);
|
2018-07-31 03:55:40 +00:00
|
|
|
qpair_ctx->qid = qpair->qid;
|
2018-06-14 17:27:37 +00:00
|
|
|
|
2018-11-21 02:11:25 +00:00
|
|
|
/* Find the tgroup and remove the qpair from the tgroup */
|
|
|
|
TAILQ_FOREACH(tgroup, &qpair->group->tgroups, link) {
|
|
|
|
if (tgroup->transport == qpair->transport) {
|
|
|
|
rc = spdk_nvmf_transport_poll_group_remove(tgroup, qpair);
|
|
|
|
if (rc && (rc != ENOTSUP)) {
|
|
|
|
SPDK_ERRLOG("Cannot remove qpair=%p from transport group=%p\n",
|
|
|
|
qpair, tgroup);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-22 22:47:55 +00:00
|
|
|
if (ctrlr) {
|
|
|
|
sgroup = &qpair->group->sgroups[ctrlr->subsys->id];
|
|
|
|
TAILQ_FOREACH_SAFE(req, &sgroup->queued, link, tmp) {
|
|
|
|
if (req->qpair == qpair) {
|
|
|
|
TAILQ_REMOVE(&sgroup->queued, req, link);
|
|
|
|
if (spdk_nvmf_transport_req_free(req)) {
|
|
|
|
SPDK_ERRLOG("Transport request free error!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 17:16:23 +00:00
|
|
|
TAILQ_REMOVE(&qpair->group->qpairs, qpair, link);
|
|
|
|
|
2018-06-14 17:27:37 +00:00
|
|
|
spdk_nvmf_transport_qpair_fini(qpair);
|
|
|
|
|
2018-08-13 17:26:26 +00:00
|
|
|
if (!ctrlr || !ctrlr->thread) {
|
2018-06-29 19:09:47 +00:00
|
|
|
if (qpair_ctx->cb_fn) {
|
2018-07-19 22:50:34 +00:00
|
|
|
spdk_thread_send_msg(qpair_ctx->thread, qpair_ctx->cb_fn, qpair_ctx->ctx);
|
2018-06-29 19:09:47 +00:00
|
|
|
}
|
|
|
|
free(qpair_ctx);
|
2018-06-01 22:10:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-14 17:27:37 +00:00
|
|
|
|
2018-07-31 03:55:40 +00:00
|
|
|
qpair_ctx->ctrlr = ctrlr;
|
2018-08-13 17:26:26 +00:00
|
|
|
spdk_thread_send_msg(ctrlr->thread, _spdk_nvmf_ctrlr_free_from_qpair, qpair_ctx);
|
2018-06-14 17:27:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-29 19:09:47 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_cb cb_fn, void *ctx)
|
2018-06-14 17:27:37 +00:00
|
|
|
{
|
2018-09-04 18:37:31 +00:00
|
|
|
struct nvmf_qpair_disconnect_ctx *qpair_ctx;
|
2018-06-29 19:09:47 +00:00
|
|
|
|
2018-07-27 19:21:00 +00:00
|
|
|
/* If we get a qpair in the uninitialized state, we can just destroy it immediately */
|
|
|
|
if (qpair->state == SPDK_NVMF_QPAIR_UNINITIALIZED) {
|
|
|
|
spdk_nvmf_transport_qpair_fini(qpair);
|
|
|
|
if (cb_fn) {
|
|
|
|
cb_fn(ctx);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-04 18:37:31 +00:00
|
|
|
/* The queue pair must be disconnected from the thread that owns it */
|
|
|
|
assert(qpair->group->thread == spdk_get_thread());
|
|
|
|
|
2018-10-24 19:12:23 +00:00
|
|
|
if (qpair->state != SPDK_NVMF_QPAIR_ACTIVE) {
|
2018-09-04 18:46:31 +00:00
|
|
|
/* This can occur if the connection is killed by the target,
|
|
|
|
* which results in a notification that the connection
|
|
|
|
* died. Send a message to defer the processing of this
|
|
|
|
* callback. This allows the stack to unwind in the case
|
|
|
|
* where a bunch of connections are disconnected in
|
|
|
|
* a loop. */
|
|
|
|
if (cb_fn) {
|
|
|
|
spdk_thread_send_msg(qpair->group->thread, cb_fn, ctx);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2018-09-04 18:37:31 +00:00
|
|
|
|
2018-09-04 18:46:31 +00:00
|
|
|
assert(qpair->state == SPDK_NVMF_QPAIR_ACTIVE);
|
|
|
|
spdk_nvmf_qpair_set_state(qpair, SPDK_NVMF_QPAIR_DEACTIVATING);
|
|
|
|
|
|
|
|
qpair_ctx = calloc(1, sizeof(struct nvmf_qpair_disconnect_ctx));
|
2018-09-04 18:37:31 +00:00
|
|
|
if (!qpair_ctx) {
|
|
|
|
SPDK_ERRLOG("Unable to allocate context for nvmf_qpair_disconnect\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2018-06-29 19:09:47 +00:00
|
|
|
qpair_ctx->qpair = qpair;
|
|
|
|
qpair_ctx->cb_fn = cb_fn;
|
2018-07-19 22:50:34 +00:00
|
|
|
qpair_ctx->thread = qpair->group->thread;
|
2018-06-29 19:09:47 +00:00
|
|
|
qpair_ctx->ctx = ctx;
|
2018-09-04 18:46:31 +00:00
|
|
|
|
|
|
|
/* Check for outstanding I/O */
|
|
|
|
if (!TAILQ_EMPTY(&qpair->outstanding)) {
|
|
|
|
qpair->state_cb = _spdk_nvmf_qpair_destroy;
|
|
|
|
qpair->state_cb_arg = qpair_ctx;
|
|
|
|
spdk_nvmf_qpair_free_aer(qpair);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_spdk_nvmf_qpair_destroy(qpair_ctx, 0);
|
|
|
|
|
2018-06-29 19:09:47 +00:00
|
|
|
return 0;
|
2018-06-14 17:27:37 +00:00
|
|
|
}
|
|
|
|
|
2018-08-02 22:08:12 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_qpair_get_peer_trid(struct spdk_nvmf_qpair *qpair,
|
|
|
|
struct spdk_nvme_transport_id *trid)
|
|
|
|
{
|
|
|
|
return spdk_nvmf_transport_qpair_get_peer_trid(qpair, trid);
|
|
|
|
}
|
|
|
|
|
2018-09-10 21:28:04 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_qpair_get_local_trid(struct spdk_nvmf_qpair *qpair,
|
|
|
|
struct spdk_nvme_transport_id *trid)
|
|
|
|
{
|
|
|
|
return spdk_nvmf_transport_qpair_get_local_trid(qpair, trid);
|
|
|
|
}
|
|
|
|
|
2018-09-07 20:41:41 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_qpair_get_listen_trid(struct spdk_nvmf_qpair *qpair,
|
|
|
|
struct spdk_nvme_transport_id *trid)
|
|
|
|
{
|
|
|
|
return spdk_nvmf_transport_qpair_get_listen_trid(qpair, trid);
|
|
|
|
}
|
|
|
|
|
2017-11-17 17:01:39 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_poll_group_add_transport(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_transport *transport)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_transport_poll_group *tgroup;
|
|
|
|
|
2018-01-17 01:06:52 +00:00
|
|
|
TAILQ_FOREACH(tgroup, &group->tgroups, link) {
|
|
|
|
if (tgroup->transport == transport) {
|
|
|
|
/* Transport already in the poll group */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-17 17:01:39 +00:00
|
|
|
tgroup = spdk_nvmf_transport_poll_group_create(transport);
|
|
|
|
if (!tgroup) {
|
|
|
|
SPDK_ERRLOG("Unable to create poll group for transport\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-05-15 12:40:12 +00:00
|
|
|
tgroup->group = group;
|
2017-11-17 17:01:39 +00:00
|
|
|
TAILQ_INSERT_TAIL(&group->tgroups, tgroup, link);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
static int
|
|
|
|
poll_group_update_subsystem(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem)
|
2017-11-20 16:50:10 +00:00
|
|
|
{
|
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
2019-03-01 04:21:37 +00:00
|
|
|
uint32_t new_num_ns, old_num_ns;
|
2019-03-15 02:40:19 +00:00
|
|
|
uint32_t i, j;
|
2017-12-19 23:39:04 +00:00
|
|
|
struct spdk_nvmf_ns *ns;
|
2019-03-15 02:40:19 +00:00
|
|
|
struct spdk_nvmf_registrant *reg, *tmp;
|
2019-06-28 08:50:02 +00:00
|
|
|
struct spdk_io_channel *ch;
|
2019-06-28 09:35:05 +00:00
|
|
|
struct spdk_nvmf_subsystem_pg_ns_info *ns_info;
|
2019-08-08 21:15:17 +00:00
|
|
|
struct spdk_nvmf_ctrlr *ctrlr;
|
|
|
|
bool ns_changed;
|
2017-11-20 16:50:10 +00:00
|
|
|
|
2018-04-05 20:51:51 +00:00
|
|
|
/* Make sure our poll group has memory for this subsystem allocated */
|
2017-11-20 16:50:10 +00:00
|
|
|
if (subsystem->id >= group->num_sgroups) {
|
2018-05-08 23:05:28 +00:00
|
|
|
return -ENOMEM;
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sgroup = &group->sgroups[subsystem->id];
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
/* Make sure the array of namespace information is the correct size */
|
|
|
|
new_num_ns = subsystem->max_nsid;
|
|
|
|
old_num_ns = sgroup->num_ns;
|
2017-12-19 23:39:04 +00:00
|
|
|
|
2019-08-08 21:15:17 +00:00
|
|
|
ns_changed = false;
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
if (old_num_ns == 0) {
|
|
|
|
if (new_num_ns > 0) {
|
2018-04-05 20:51:51 +00:00
|
|
|
/* First allocation */
|
2019-03-01 04:21:37 +00:00
|
|
|
sgroup->ns_info = calloc(new_num_ns, sizeof(struct spdk_nvmf_subsystem_pg_ns_info));
|
|
|
|
if (!sgroup->ns_info) {
|
2018-04-05 20:51:51 +00:00
|
|
|
return -ENOMEM;
|
2018-03-21 06:16:23 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-01 04:21:37 +00:00
|
|
|
} else if (new_num_ns > old_num_ns) {
|
2018-04-05 20:51:51 +00:00
|
|
|
void *buf;
|
|
|
|
|
|
|
|
/* Make the array larger */
|
2019-03-01 04:21:37 +00:00
|
|
|
buf = realloc(sgroup->ns_info, new_num_ns * sizeof(struct spdk_nvmf_subsystem_pg_ns_info));
|
2018-04-05 20:51:51 +00:00
|
|
|
if (!buf) {
|
2017-12-19 23:39:04 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
sgroup->ns_info = buf;
|
2018-04-05 20:51:51 +00:00
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
/* Null out the new namespace information slots */
|
|
|
|
for (i = old_num_ns; i < new_num_ns; i++) {
|
|
|
|
memset(&sgroup->ns_info[i], 0, sizeof(struct spdk_nvmf_subsystem_pg_ns_info));
|
2017-12-19 23:39:04 +00:00
|
|
|
}
|
2019-03-01 04:21:37 +00:00
|
|
|
} else if (new_num_ns < old_num_ns) {
|
2018-04-05 20:51:51 +00:00
|
|
|
void *buf;
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
/* Free the extra I/O channels */
|
2019-03-01 04:21:37 +00:00
|
|
|
for (i = new_num_ns; i < old_num_ns; i++) {
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info = &sgroup->ns_info[i];
|
|
|
|
|
|
|
|
if (ns_info->channel) {
|
|
|
|
spdk_put_io_channel(ns_info->channel);
|
|
|
|
ns_info->channel = NULL;
|
2017-12-19 23:39:04 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-20 16:50:10 +00:00
|
|
|
|
2018-04-05 20:51:51 +00:00
|
|
|
/* Make the array smaller */
|
2019-03-01 04:21:37 +00:00
|
|
|
if (new_num_ns > 0) {
|
|
|
|
buf = realloc(sgroup->ns_info, new_num_ns * sizeof(struct spdk_nvmf_subsystem_pg_ns_info));
|
2018-04-05 20:51:51 +00:00
|
|
|
if (!buf) {
|
|
|
|
return -ENOMEM;
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
2019-03-01 04:21:37 +00:00
|
|
|
sgroup->ns_info = buf;
|
2018-04-05 20:51:51 +00:00
|
|
|
} else {
|
2019-03-01 04:21:37 +00:00
|
|
|
free(sgroup->ns_info);
|
|
|
|
sgroup->ns_info = NULL;
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
sgroup->num_ns = new_num_ns;
|
2018-04-05 20:51:51 +00:00
|
|
|
|
|
|
|
/* Detect bdevs that were added or removed */
|
2019-03-01 04:21:37 +00:00
|
|
|
for (i = 0; i < sgroup->num_ns; i++) {
|
2018-04-05 20:51:51 +00:00
|
|
|
ns = subsystem->ns[i];
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info = &sgroup->ns_info[i];
|
|
|
|
ch = ns_info->channel;
|
2019-06-28 08:50:02 +00:00
|
|
|
|
|
|
|
if (ns == NULL && ch == NULL) {
|
2018-04-05 20:51:51 +00:00
|
|
|
/* Both NULL. Leave empty */
|
2019-06-28 08:50:02 +00:00
|
|
|
} else if (ns == NULL && ch != NULL) {
|
2018-04-05 20:51:51 +00:00
|
|
|
/* There was a channel here, but the namespace is gone. */
|
2019-08-08 21:15:17 +00:00
|
|
|
ns_changed = true;
|
2019-06-28 08:50:02 +00:00
|
|
|
spdk_put_io_channel(ch);
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info->channel = NULL;
|
2019-06-28 08:50:02 +00:00
|
|
|
} else if (ns != NULL && ch == NULL) {
|
2018-04-05 20:51:51 +00:00
|
|
|
/* A namespace appeared but there is no channel yet */
|
2019-08-08 21:15:17 +00:00
|
|
|
ns_changed = true;
|
2019-06-28 09:35:05 +00:00
|
|
|
ch = spdk_bdev_get_io_channel(ns->desc);
|
|
|
|
if (ch == NULL) {
|
2018-06-25 03:02:16 +00:00
|
|
|
SPDK_ERRLOG("Could not allocate I/O channel.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info->channel = ch;
|
2019-06-27 11:24:12 +00:00
|
|
|
} else if (spdk_uuid_compare(&ns_info->uuid, spdk_bdev_get_uuid(ns->bdev)) != 0) {
|
|
|
|
/* A namespace was here before, but was replaced by a new one. */
|
2019-08-08 21:15:17 +00:00
|
|
|
ns_changed = true;
|
2019-06-27 11:24:12 +00:00
|
|
|
spdk_put_io_channel(ns_info->channel);
|
|
|
|
memset(ns_info, 0, sizeof(*ns_info));
|
|
|
|
|
|
|
|
ch = spdk_bdev_get_io_channel(ns->desc);
|
|
|
|
if (ch == NULL) {
|
|
|
|
SPDK_ERRLOG("Could not allocate I/O channel.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
ns_info->channel = ch;
|
2019-09-11 14:47:39 +00:00
|
|
|
} else if (ns_info->num_blocks != spdk_bdev_get_num_blocks(ns->bdev)) {
|
|
|
|
/* Namespace is still there but size has changed */
|
|
|
|
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Namespace resized: subsystem_id %d,"
|
|
|
|
" nsid %u, pg %p, old %lu, new %lu\n",
|
|
|
|
subsystem->id,
|
|
|
|
ns->nsid,
|
|
|
|
group,
|
|
|
|
ns_info->num_blocks,
|
|
|
|
spdk_bdev_get_num_blocks(ns->bdev));
|
|
|
|
ns_changed = true;
|
2018-04-05 20:51:51 +00:00
|
|
|
}
|
2019-03-01 05:12:55 +00:00
|
|
|
|
|
|
|
if (ns == NULL) {
|
2019-06-28 09:35:05 +00:00
|
|
|
memset(ns_info, 0, sizeof(*ns_info));
|
2019-04-10 06:48:53 +00:00
|
|
|
} else {
|
2019-06-27 11:24:12 +00:00
|
|
|
ns_info->uuid = *spdk_bdev_get_uuid(ns->bdev);
|
2019-09-11 14:47:39 +00:00
|
|
|
ns_info->num_blocks = spdk_bdev_get_num_blocks(ns->bdev);
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info->crkey = ns->crkey;
|
|
|
|
ns_info->rtype = ns->rtype;
|
2019-04-10 06:48:53 +00:00
|
|
|
if (ns->holder) {
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info->holder_id = ns->holder->hostid;
|
2019-04-10 06:48:53 +00:00
|
|
|
}
|
2019-03-15 02:40:19 +00:00
|
|
|
|
2019-06-28 09:35:05 +00:00
|
|
|
memset(&ns_info->reg_hostid, 0, SPDK_NVMF_MAX_NUM_REGISTRANTS * sizeof(struct spdk_uuid));
|
2019-03-15 02:40:19 +00:00
|
|
|
j = 0;
|
|
|
|
TAILQ_FOREACH_SAFE(reg, &ns->registrants, link, tmp) {
|
|
|
|
if (j >= SPDK_NVMF_MAX_NUM_REGISTRANTS) {
|
|
|
|
SPDK_ERRLOG("Maximum %u registrants can support.\n", SPDK_NVMF_MAX_NUM_REGISTRANTS);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-06-28 09:35:05 +00:00
|
|
|
ns_info->reg_hostid[j++] = reg->hostid;
|
2019-03-15 02:40:19 +00:00
|
|
|
}
|
2019-03-01 05:12:55 +00:00
|
|
|
}
|
2018-04-05 20:51:51 +00:00
|
|
|
}
|
2017-12-19 23:39:04 +00:00
|
|
|
|
2019-08-08 21:15:17 +00:00
|
|
|
if (ns_changed) {
|
|
|
|
TAILQ_FOREACH(ctrlr, &subsystem->ctrlrs, link) {
|
|
|
|
if (ctrlr->admin_qpair->group == group) {
|
|
|
|
spdk_nvmf_ctrlr_async_event_ns_notice(ctrlr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-20 16:50:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:31:40 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_poll_group_update_subsystem(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem)
|
|
|
|
{
|
|
|
|
return poll_group_update_subsystem(group, subsystem);
|
|
|
|
}
|
|
|
|
|
2018-08-28 22:41:16 +00:00
|
|
|
int
|
2017-12-19 23:39:04 +00:00
|
|
|
spdk_nvmf_poll_group_add_subsystem(struct spdk_nvmf_poll_group *group,
|
2018-07-13 23:23:23 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg)
|
2017-12-14 02:38:18 +00:00
|
|
|
{
|
2018-07-13 23:23:23 +00:00
|
|
|
int rc = 0;
|
2018-08-20 22:48:27 +00:00
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup = &group->sgroups[subsystem->id];
|
|
|
|
|
|
|
|
TAILQ_INIT(&sgroup->queued);
|
2017-12-14 02:38:18 +00:00
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
rc = poll_group_update_subsystem(group, subsystem);
|
|
|
|
if (rc) {
|
2018-08-28 22:41:16 +00:00
|
|
|
spdk_nvmf_poll_group_remove_subsystem(group, subsystem, NULL, NULL);
|
2018-07-13 23:23:23 +00:00
|
|
|
goto fini;
|
2017-12-14 02:38:18 +00:00
|
|
|
}
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
sgroup->state = SPDK_NVMF_SUBSYSTEM_ACTIVE;
|
2018-07-13 23:23:23 +00:00
|
|
|
fini:
|
|
|
|
if (cb_fn) {
|
|
|
|
cb_fn(cb_arg, rc);
|
|
|
|
}
|
2018-08-28 22:41:16 +00:00
|
|
|
|
|
|
|
return rc;
|
2017-12-14 02:38:18 +00:00
|
|
|
}
|
|
|
|
|
2018-06-29 20:15:15 +00:00
|
|
|
static void
|
|
|
|
_nvmf_poll_group_remove_subsystem_cb(void *ctx, int status)
|
2017-11-20 16:50:10 +00:00
|
|
|
{
|
2018-07-13 23:23:23 +00:00
|
|
|
struct nvmf_qpair_disconnect_many_ctx *qpair_ctx = ctx;
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
struct spdk_nvmf_poll_group *group;
|
2017-11-20 16:50:10 +00:00
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
2018-07-13 23:23:23 +00:00
|
|
|
spdk_nvmf_poll_group_mod_done cpl_fn = NULL;
|
|
|
|
void *cpl_ctx = NULL;
|
2017-11-20 16:50:10 +00:00
|
|
|
uint32_t nsid;
|
|
|
|
|
2018-07-13 23:23:23 +00:00
|
|
|
group = qpair_ctx->group;
|
|
|
|
subsystem = qpair_ctx->subsystem;
|
|
|
|
cpl_fn = qpair_ctx->cpl_fn;
|
|
|
|
cpl_ctx = qpair_ctx->cpl_ctx;
|
|
|
|
sgroup = &group->sgroups[subsystem->id];
|
|
|
|
|
2018-06-29 20:15:15 +00:00
|
|
|
if (status) {
|
2018-07-13 23:23:23 +00:00
|
|
|
goto fini;
|
2018-06-01 22:10:12 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
for (nsid = 0; nsid < sgroup->num_ns; nsid++) {
|
|
|
|
if (sgroup->ns_info[nsid].channel) {
|
|
|
|
spdk_put_io_channel(sgroup->ns_info[nsid].channel);
|
|
|
|
sgroup->ns_info[nsid].channel = NULL;
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
sgroup->num_ns = 0;
|
|
|
|
free(sgroup->ns_info);
|
|
|
|
sgroup->ns_info = NULL;
|
2018-07-13 23:23:23 +00:00
|
|
|
fini:
|
|
|
|
free(qpair_ctx);
|
|
|
|
if (cpl_fn) {
|
|
|
|
cpl_fn(cpl_ctx, status);
|
|
|
|
}
|
2018-06-29 20:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_nvmf_subsystem_disconnect_next_qpair(void *ctx)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_qpair *qpair;
|
|
|
|
struct nvmf_qpair_disconnect_many_ctx *qpair_ctx = ctx;
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
struct spdk_nvmf_poll_group *group;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
group = qpair_ctx->group;
|
|
|
|
subsystem = qpair_ctx->subsystem;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(qpair, &group->qpairs, link) {
|
2018-12-12 17:39:44 +00:00
|
|
|
if ((qpair->ctrlr != NULL) && (qpair->ctrlr->subsys == subsystem)) {
|
2018-06-29 20:15:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qpair) {
|
|
|
|
rc = spdk_nvmf_qpair_disconnect(qpair, _nvmf_subsystem_disconnect_next_qpair, qpair_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!qpair || rc != 0) {
|
2018-07-13 23:23:23 +00:00
|
|
|
_nvmf_poll_group_remove_subsystem_cb(ctx, rc);
|
2018-06-29 20:15:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-13 23:23:23 +00:00
|
|
|
void
|
2018-06-29 20:15:15 +00:00
|
|
|
spdk_nvmf_poll_group_remove_subsystem(struct spdk_nvmf_poll_group *group,
|
2018-07-13 23:23:23 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg)
|
2018-06-29 20:15:15 +00:00
|
|
|
{
|
|
|
|
struct spdk_nvmf_qpair *qpair;
|
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
|
|
|
struct nvmf_qpair_disconnect_many_ctx *ctx;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
ctx = calloc(1, sizeof(struct nvmf_qpair_disconnect_many_ctx));
|
|
|
|
|
|
|
|
if (!ctx) {
|
2018-07-13 23:23:23 +00:00
|
|
|
SPDK_ERRLOG("Unable to allocate memory for context to remove poll subsystem\n");
|
|
|
|
goto fini;
|
2018-06-29 20:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx->group = group;
|
|
|
|
ctx->subsystem = subsystem;
|
2018-07-13 23:23:23 +00:00
|
|
|
ctx->cpl_fn = cb_fn;
|
|
|
|
ctx->cpl_ctx = cb_arg;
|
2018-06-29 20:15:15 +00:00
|
|
|
|
|
|
|
sgroup = &group->sgroups[subsystem->id];
|
|
|
|
sgroup->state = SPDK_NVMF_SUBSYSTEM_INACTIVE;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(qpair, &group->qpairs, link) {
|
2018-12-12 17:39:44 +00:00
|
|
|
if ((qpair->ctrlr != NULL) && (qpair->ctrlr->subsys == subsystem)) {
|
2018-06-29 20:15:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qpair) {
|
|
|
|
rc = spdk_nvmf_qpair_disconnect(qpair, _nvmf_subsystem_disconnect_next_qpair, ctx);
|
|
|
|
} else {
|
2018-07-13 23:23:23 +00:00
|
|
|
/* call the callback immediately. It will handle any channel iteration */
|
|
|
|
_nvmf_poll_group_remove_subsystem_cb(ctx, 0);
|
2018-06-29 20:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != 0) {
|
|
|
|
free(ctx);
|
2018-07-13 23:23:23 +00:00
|
|
|
goto fini;
|
2018-06-29 20:15:15 +00:00
|
|
|
}
|
2017-11-20 16:50:10 +00:00
|
|
|
|
2018-07-13 23:23:23 +00:00
|
|
|
return;
|
|
|
|
fini:
|
|
|
|
if (cb_fn) {
|
|
|
|
cb_fn(cb_arg, rc);
|
|
|
|
}
|
2017-11-20 16:50:10 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 23:23:23 +00:00
|
|
|
void
|
2017-12-19 23:39:04 +00:00
|
|
|
spdk_nvmf_poll_group_pause_subsystem(struct spdk_nvmf_poll_group *group,
|
2018-07-13 23:23:23 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg)
|
2017-11-20 17:45:39 +00:00
|
|
|
{
|
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
2018-07-13 23:23:23 +00:00
|
|
|
int rc = 0;
|
2017-11-20 17:45:39 +00:00
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
if (subsystem->id >= group->num_sgroups) {
|
2018-07-13 23:23:23 +00:00
|
|
|
rc = -1;
|
|
|
|
goto fini;
|
2017-12-19 23:39:04 +00:00
|
|
|
}
|
2017-11-20 17:45:39 +00:00
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
sgroup = &group->sgroups[subsystem->id];
|
|
|
|
if (sgroup == NULL) {
|
2018-07-13 23:23:23 +00:00
|
|
|
rc = -1;
|
|
|
|
goto fini;
|
2017-12-19 23:39:04 +00:00
|
|
|
}
|
2017-11-20 17:45:39 +00:00
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
assert(sgroup->state == SPDK_NVMF_SUBSYSTEM_ACTIVE);
|
2019-04-25 14:03:06 +00:00
|
|
|
sgroup->state = SPDK_NVMF_SUBSYSTEM_PAUSING;
|
|
|
|
|
|
|
|
if (sgroup->io_outstanding > 0) {
|
|
|
|
sgroup->cb_fn = cb_fn;
|
|
|
|
sgroup->cb_arg = cb_arg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(sgroup->io_outstanding == 0);
|
2017-12-19 23:39:04 +00:00
|
|
|
sgroup->state = SPDK_NVMF_SUBSYSTEM_PAUSED;
|
2018-07-13 23:23:23 +00:00
|
|
|
fini:
|
|
|
|
if (cb_fn) {
|
|
|
|
cb_fn(cb_arg, rc);
|
|
|
|
}
|
2017-12-19 23:39:04 +00:00
|
|
|
}
|
2017-11-20 17:45:39 +00:00
|
|
|
|
2018-07-13 23:23:23 +00:00
|
|
|
void
|
2017-12-19 23:39:04 +00:00
|
|
|
spdk_nvmf_poll_group_resume_subsystem(struct spdk_nvmf_poll_group *group,
|
2018-07-13 23:23:23 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg)
|
2017-12-19 23:39:04 +00:00
|
|
|
{
|
2018-04-04 16:16:39 +00:00
|
|
|
struct spdk_nvmf_request *req, *tmp;
|
|
|
|
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
2018-07-13 23:23:23 +00:00
|
|
|
int rc = 0;
|
2017-11-20 17:45:39 +00:00
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
if (subsystem->id >= group->num_sgroups) {
|
2018-07-13 23:23:23 +00:00
|
|
|
rc = -1;
|
|
|
|
goto fini;
|
2017-11-20 17:45:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 16:16:39 +00:00
|
|
|
sgroup = &group->sgroups[subsystem->id];
|
|
|
|
|
|
|
|
assert(sgroup->state == SPDK_NVMF_SUBSYSTEM_PAUSED);
|
2017-12-19 23:39:04 +00:00
|
|
|
|
|
|
|
rc = poll_group_update_subsystem(group, subsystem);
|
|
|
|
if (rc) {
|
2018-07-13 23:23:23 +00:00
|
|
|
goto fini;
|
2017-11-20 17:45:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 16:16:39 +00:00
|
|
|
sgroup->state = SPDK_NVMF_SUBSYSTEM_ACTIVE;
|
|
|
|
|
|
|
|
/* Release all queued requests */
|
|
|
|
TAILQ_FOREACH_SAFE(req, &sgroup->queued, link, tmp) {
|
|
|
|
TAILQ_REMOVE(&sgroup->queued, req, link);
|
|
|
|
spdk_nvmf_request_exec(req);
|
|
|
|
}
|
2018-07-13 23:23:23 +00:00
|
|
|
fini:
|
|
|
|
if (cb_fn) {
|
|
|
|
cb_fn(cb_arg, rc);
|
|
|
|
}
|
2017-11-20 17:45:39 +00:00
|
|
|
}
|
2019-05-15 12:40:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct spdk_nvmf_poll_group *
|
|
|
|
spdk_nvmf_get_optimal_poll_group(struct spdk_nvmf_qpair *qpair)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_transport_poll_group *tgroup;
|
|
|
|
|
|
|
|
tgroup = spdk_nvmf_transport_get_optimal_poll_group(qpair->transport, qpair);
|
|
|
|
|
|
|
|
if (tgroup == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tgroup->group;
|
|
|
|
}
|
2019-04-15 09:54:38 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
spdk_nvmf_poll_group_get_stat(struct spdk_nvmf_tgt *tgt,
|
|
|
|
struct spdk_nvmf_poll_group_stat *stat)
|
|
|
|
{
|
|
|
|
struct spdk_io_channel *ch;
|
|
|
|
struct spdk_nvmf_poll_group *group;
|
|
|
|
|
|
|
|
if (tgt == NULL || stat == NULL) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ch = spdk_get_io_channel(tgt);
|
|
|
|
group = spdk_io_channel_get_ctx(ch);
|
|
|
|
*stat = group->stat;
|
2019-07-28 11:36:30 +00:00
|
|
|
spdk_put_io_channel(ch);
|
2019-04-15 09:54:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|