2016-06-06 21:44:30 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2016-08-23 16:46:41 +00:00
|
|
|
#include "nvmf_tgt.h"
|
2016-08-15 23:25:11 +00:00
|
|
|
|
2016-09-19 17:01:52 +00:00
|
|
|
#include "spdk/bdev.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
#include "spdk/event.h"
|
2017-11-14 20:42:17 +00:00
|
|
|
#include "spdk/io_channel.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
#include "spdk/log.h"
|
|
|
|
#include "spdk/nvme.h"
|
2017-09-25 22:27:01 +00:00
|
|
|
#include "spdk/util.h"
|
|
|
|
|
|
|
|
struct nvmf_tgt_poll_group {
|
|
|
|
struct spdk_nvmf_poll_group *group;
|
|
|
|
};
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2017-11-01 23:24:18 +00:00
|
|
|
struct nvmf_tgt g_tgt = {};
|
2017-08-18 22:38:33 +00:00
|
|
|
|
2017-09-25 22:27:01 +00:00
|
|
|
static struct nvmf_tgt_poll_group *g_poll_groups = NULL;
|
|
|
|
static size_t g_num_poll_groups = 0;
|
|
|
|
static size_t g_active_poll_groups = 0;
|
|
|
|
|
2016-08-16 16:35:59 +00:00
|
|
|
static struct spdk_poller *g_acceptor_poller = NULL;
|
|
|
|
|
2017-11-01 23:24:18 +00:00
|
|
|
static void nvmf_tgt_advance_state(void *arg1, void *arg2);
|
2016-08-25 22:00:50 +00:00
|
|
|
|
2016-08-16 16:35:59 +00:00
|
|
|
static void
|
nvmf/tgt: Fix issues for ctrlr+ c handling.
When receving ctrlr+c event, NVMe-oF target
could in any state. So we cannot guarantee
g_acceptor_poller is initialized or not. If
we do not handle such case, ctrlr+c will
trigger unexpected coredump issue. To
solve this issue, following methods are used.
Currently, our code in event module (lib/event/app.c)
can only receive ctrlr + c command once, so
when we receive the ctrlr+c, we should complete
the shutdown process.
The idea is to use spdk_event_call, we will only
enter shutdown process if tgt is in NVMF_TGT_RUNNING
status.
After several patch tries, I think that this solution
is much simple. Though we would like to kill after
entering the running state, it may wait some time
if users kill the application in early state, but those
operations will not be quite often in real case.
Change-Id: Id89a96b5d39f8a528e72dea8c0eb6524bdaf7ee4
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/389433
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-12-08 10:57:43 +00:00
|
|
|
_spdk_nvmf_shutdown_cb(void *arg1, void *arg2)
|
2016-08-16 16:35:59 +00:00
|
|
|
{
|
nvmf/tgt: Fix issues for ctrlr+ c handling.
When receving ctrlr+c event, NVMe-oF target
could in any state. So we cannot guarantee
g_acceptor_poller is initialized or not. If
we do not handle such case, ctrlr+c will
trigger unexpected coredump issue. To
solve this issue, following methods are used.
Currently, our code in event module (lib/event/app.c)
can only receive ctrlr + c command once, so
when we receive the ctrlr+c, we should complete
the shutdown process.
The idea is to use spdk_event_call, we will only
enter shutdown process if tgt is in NVMF_TGT_RUNNING
status.
After several patch tries, I think that this solution
is much simple. Though we would like to kill after
entering the running state, it may wait some time
if users kill the application in early state, but those
operations will not be quite often in real case.
Change-Id: Id89a96b5d39f8a528e72dea8c0eb6524bdaf7ee4
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/389433
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-12-08 10:57:43 +00:00
|
|
|
/* Still in initialization state, defer shutdown operation */
|
|
|
|
if (g_tgt.state < NVMF_TGT_RUNNING) {
|
|
|
|
spdk_event_call(spdk_event_allocate(spdk_env_get_current_core(),
|
|
|
|
_spdk_nvmf_shutdown_cb, NULL, NULL));
|
|
|
|
return;
|
|
|
|
} else if (g_tgt.state > NVMF_TGT_RUNNING) {
|
|
|
|
/* Already in Shutdown status, ignore the signal */
|
|
|
|
return;
|
|
|
|
}
|
2016-08-16 16:35:59 +00:00
|
|
|
|
2017-11-01 23:24:18 +00:00
|
|
|
g_tgt.state = NVMF_TGT_FINI_STOP_ACCEPTOR;
|
|
|
|
nvmf_tgt_advance_state(NULL, NULL);
|
2016-06-06 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
nvmf/tgt: Fix issues for ctrlr+ c handling.
When receving ctrlr+c event, NVMe-oF target
could in any state. So we cannot guarantee
g_acceptor_poller is initialized or not. If
we do not handle such case, ctrlr+c will
trigger unexpected coredump issue. To
solve this issue, following methods are used.
Currently, our code in event module (lib/event/app.c)
can only receive ctrlr + c command once, so
when we receive the ctrlr+c, we should complete
the shutdown process.
The idea is to use spdk_event_call, we will only
enter shutdown process if tgt is in NVMF_TGT_RUNNING
status.
After several patch tries, I think that this solution
is much simple. Though we would like to kill after
entering the running state, it may wait some time
if users kill the application in early state, but those
operations will not be quite often in real case.
Change-Id: Id89a96b5d39f8a528e72dea8c0eb6524bdaf7ee4
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/389433
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-12-08 10:57:43 +00:00
|
|
|
static void
|
|
|
|
spdk_nvmf_shutdown_cb(void)
|
|
|
|
{
|
|
|
|
printf("\n=========================\n");
|
|
|
|
printf(" NVMF shutdown signal\n");
|
|
|
|
printf("=========================\n");
|
|
|
|
|
|
|
|
/* Always let the first core to handle the case */
|
|
|
|
if (spdk_env_get_current_core() != spdk_env_get_first_core()) {
|
|
|
|
spdk_event_call(spdk_event_allocate(spdk_env_get_first_core(),
|
|
|
|
_spdk_nvmf_shutdown_cb, NULL, NULL));
|
|
|
|
} else {
|
|
|
|
_spdk_nvmf_shutdown_cb(NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-20 18:36:36 +00:00
|
|
|
struct spdk_nvmf_subsystem *
|
|
|
|
nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype, uint32_t num_ns)
|
2016-08-25 22:00:50 +00:00
|
|
|
{
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
|
2017-11-01 23:24:18 +00:00
|
|
|
if (spdk_nvmf_tgt_find_subsystem(g_tgt.tgt, name)) {
|
2016-11-18 08:16:37 +00:00
|
|
|
SPDK_ERRLOG("Subsystem already exist\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
subsystem = spdk_nvmf_subsystem_create(g_tgt.tgt, name, subtype, num_ns);
|
2016-08-25 22:00:50 +00:00
|
|
|
if (subsystem == NULL) {
|
|
|
|
SPDK_ERRLOG("Subsystem creation failed\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-11-20 18:36:36 +00:00
|
|
|
SPDK_NOTICELOG("allocated subsystem %s\n", name);
|
2016-08-25 22:00:50 +00:00
|
|
|
|
2017-11-20 18:36:36 +00:00
|
|
|
return subsystem;
|
2016-09-13 02:52:21 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 16:36:33 +00:00
|
|
|
static void
|
|
|
|
nvmf_tgt_poll_group_add(void *arg1, void *arg2)
|
|
|
|
{
|
|
|
|
struct spdk_nvmf_qpair *qpair = arg1;
|
|
|
|
struct nvmf_tgt_poll_group *pg = arg2;
|
|
|
|
|
|
|
|
spdk_nvmf_poll_group_add(pg->group, qpair);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_qpair(struct spdk_nvmf_qpair *qpair)
|
|
|
|
{
|
|
|
|
struct spdk_event *event;
|
|
|
|
struct nvmf_tgt_poll_group *pg;
|
|
|
|
uint32_t core;
|
|
|
|
|
|
|
|
core = g_tgt.core;
|
|
|
|
g_tgt.core = spdk_env_get_next_core(core);
|
|
|
|
if (g_tgt.core == UINT32_MAX) {
|
|
|
|
g_tgt.core = spdk_env_get_first_core();
|
|
|
|
}
|
|
|
|
|
|
|
|
pg = &g_poll_groups[core];
|
|
|
|
assert(pg != NULL);
|
|
|
|
|
|
|
|
event = spdk_event_allocate(core, nvmf_tgt_poll_group_add, qpair, pg);
|
|
|
|
spdk_event_call(event);
|
|
|
|
}
|
|
|
|
|
2016-08-16 16:35:59 +00:00
|
|
|
static void
|
|
|
|
acceptor_poll(void *arg)
|
|
|
|
{
|
2017-08-21 21:07:44 +00:00
|
|
|
struct spdk_nvmf_tgt *tgt = arg;
|
|
|
|
|
2017-08-30 16:36:33 +00:00
|
|
|
spdk_nvmf_tgt_accept(tgt, new_qpair);
|
2016-08-16 16:35:59 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 20:44:10 +00:00
|
|
|
static void
|
2017-11-17 18:43:45 +00:00
|
|
|
nvmf_tgt_destroy_poll_group_done(void *ctx)
|
2017-11-03 20:44:10 +00:00
|
|
|
{
|
2017-11-20 18:36:36 +00:00
|
|
|
g_tgt.state = NVMF_TGT_FINI_FREE_RESOURCES;
|
2017-11-03 20:44:10 +00:00
|
|
|
nvmf_tgt_advance_state(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-11-17 18:43:45 +00:00
|
|
|
nvmf_tgt_destroy_poll_group(void *ctx)
|
2017-11-03 20:44:10 +00:00
|
|
|
{
|
|
|
|
struct nvmf_tgt_poll_group *pg;
|
|
|
|
|
2017-11-17 18:43:45 +00:00
|
|
|
pg = &g_poll_groups[spdk_env_get_current_core()];
|
2017-11-03 20:44:10 +00:00
|
|
|
assert(pg != NULL);
|
|
|
|
|
|
|
|
spdk_nvmf_poll_group_destroy(pg->group);
|
|
|
|
pg->group = NULL;
|
|
|
|
|
|
|
|
assert(g_active_poll_groups > 0);
|
|
|
|
g_active_poll_groups--;
|
|
|
|
}
|
|
|
|
|
2017-11-02 23:03:10 +00:00
|
|
|
static void
|
2017-11-17 18:43:45 +00:00
|
|
|
nvmf_tgt_create_poll_group_done(void *ctx)
|
2017-11-02 23:03:10 +00:00
|
|
|
{
|
2017-12-19 23:39:04 +00:00
|
|
|
g_tgt.state = NVMF_TGT_INIT_START_SUBSYSTEMS;
|
2017-11-02 23:03:10 +00:00
|
|
|
nvmf_tgt_advance_state(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-11-17 18:43:45 +00:00
|
|
|
nvmf_tgt_create_poll_group(void *ctx)
|
2017-11-02 23:03:10 +00:00
|
|
|
{
|
|
|
|
struct nvmf_tgt_poll_group *pg;
|
|
|
|
|
2017-11-17 18:43:45 +00:00
|
|
|
pg = &g_poll_groups[spdk_env_get_current_core()];
|
|
|
|
assert(pg != NULL);
|
2017-11-02 23:03:10 +00:00
|
|
|
|
|
|
|
pg->group = spdk_nvmf_poll_group_create(g_tgt.tgt);
|
|
|
|
if (pg->group == NULL) {
|
2017-11-17 18:43:45 +00:00
|
|
|
SPDK_ERRLOG("Failed to create poll group for core %u\n", spdk_env_get_current_core());
|
2017-11-02 23:03:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-14 20:47:12 +00:00
|
|
|
g_active_poll_groups++;
|
2017-11-02 23:03:10 +00:00
|
|
|
}
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
static void
|
|
|
|
nvmf_tgt_subsystem_started(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
void *cb_arg, int status)
|
|
|
|
{
|
|
|
|
subsystem = spdk_nvmf_subsystem_get_next(subsystem);
|
|
|
|
|
|
|
|
if (subsystem) {
|
|
|
|
spdk_nvmf_subsystem_start(subsystem, nvmf_tgt_subsystem_started, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_tgt.state = NVMF_TGT_INIT_START_ACCEPTOR;
|
|
|
|
nvmf_tgt_advance_state(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nvmf_tgt_subsystem_stopped(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
void *cb_arg, int status)
|
|
|
|
{
|
|
|
|
subsystem = spdk_nvmf_subsystem_get_next(subsystem);
|
|
|
|
|
|
|
|
if (subsystem) {
|
|
|
|
spdk_nvmf_subsystem_stop(subsystem, nvmf_tgt_subsystem_stopped, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_tgt.state = NVMF_TGT_FINI_DESTROY_POLL_GROUPS;
|
|
|
|
nvmf_tgt_advance_state(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2016-06-06 21:44:30 +00:00
|
|
|
static void
|
2017-11-01 23:24:18 +00:00
|
|
|
nvmf_tgt_advance_state(void *arg1, void *arg2)
|
2016-06-06 21:44:30 +00:00
|
|
|
{
|
2017-11-01 23:24:18 +00:00
|
|
|
enum nvmf_tgt_state prev_state;
|
2017-11-02 23:03:10 +00:00
|
|
|
int rc = -1;
|
2017-11-01 23:24:18 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
prev_state = g_tgt.state;
|
|
|
|
|
|
|
|
switch (g_tgt.state) {
|
|
|
|
case NVMF_TGT_INIT_NONE: {
|
|
|
|
uint32_t core;
|
|
|
|
|
|
|
|
g_tgt.state = NVMF_TGT_INIT_PARSE_CONFIG;
|
|
|
|
|
|
|
|
/* Find the maximum core number */
|
|
|
|
SPDK_ENV_FOREACH_CORE(core) {
|
|
|
|
g_num_poll_groups = spdk_max(g_num_poll_groups, core + 1);
|
|
|
|
}
|
|
|
|
assert(g_num_poll_groups > 0);
|
|
|
|
|
|
|
|
g_poll_groups = calloc(g_num_poll_groups, sizeof(*g_poll_groups));
|
|
|
|
if (g_poll_groups == NULL) {
|
|
|
|
g_tgt.state = NVMF_TGT_ERROR;
|
|
|
|
rc = -ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
2017-08-30 16:36:33 +00:00
|
|
|
|
|
|
|
g_tgt.core = spdk_env_get_first_core();
|
2017-11-01 23:24:18 +00:00
|
|
|
break;
|
2017-09-25 22:27:01 +00:00
|
|
|
}
|
2017-11-01 23:24:18 +00:00
|
|
|
case NVMF_TGT_INIT_PARSE_CONFIG:
|
|
|
|
rc = spdk_nvmf_parse_conf();
|
|
|
|
if (rc < 0) {
|
|
|
|
SPDK_ERRLOG("spdk_nvmf_parse_conf() failed\n");
|
|
|
|
g_tgt.state = NVMF_TGT_ERROR;
|
|
|
|
rc = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2017-11-17 18:43:45 +00:00
|
|
|
g_tgt.state = NVMF_TGT_INIT_CREATE_POLL_GROUPS;
|
2017-11-01 23:24:18 +00:00
|
|
|
break;
|
2017-11-17 18:43:45 +00:00
|
|
|
case NVMF_TGT_INIT_CREATE_POLL_GROUPS:
|
|
|
|
/* Send a message to each thread and create a poll group */
|
|
|
|
spdk_for_each_thread(nvmf_tgt_create_poll_group,
|
|
|
|
NULL,
|
|
|
|
nvmf_tgt_create_poll_group_done);
|
2017-11-01 23:24:18 +00:00
|
|
|
break;
|
2017-12-19 23:39:04 +00:00
|
|
|
case NVMF_TGT_INIT_START_SUBSYSTEMS: {
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
|
|
|
|
subsystem = spdk_nvmf_subsystem_get_first(g_tgt.tgt);
|
|
|
|
|
|
|
|
if (subsystem) {
|
|
|
|
spdk_nvmf_subsystem_start(subsystem, nvmf_tgt_subsystem_started, NULL);
|
|
|
|
} else {
|
|
|
|
g_tgt.state = NVMF_TGT_INIT_START_ACCEPTOR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-11-01 23:24:18 +00:00
|
|
|
case NVMF_TGT_INIT_START_ACCEPTOR:
|
2017-11-14 20:42:17 +00:00
|
|
|
g_acceptor_poller = spdk_poller_register(acceptor_poll, g_tgt.tgt,
|
|
|
|
g_spdk_nvmf_tgt_conf.acceptor_poll_rate);
|
2017-11-14 20:51:39 +00:00
|
|
|
SPDK_NOTICELOG("Acceptor running\n");
|
2017-11-01 23:24:18 +00:00
|
|
|
g_tgt.state = NVMF_TGT_RUNNING;
|
|
|
|
break;
|
|
|
|
case NVMF_TGT_RUNNING:
|
|
|
|
if (getenv("MEMZONE_DUMP") != NULL) {
|
|
|
|
spdk_memzone_dump(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
break;
|
2017-11-17 18:43:45 +00:00
|
|
|
case NVMF_TGT_FINI_STOP_ACCEPTOR:
|
2017-11-15 22:09:40 +00:00
|
|
|
spdk_poller_unregister(&g_acceptor_poller);
|
2017-12-19 23:39:04 +00:00
|
|
|
g_tgt.state = NVMF_TGT_FINI_STOP_SUBSYSTEMS;
|
2017-11-01 23:24:18 +00:00
|
|
|
break;
|
2017-12-19 23:39:04 +00:00
|
|
|
case NVMF_TGT_FINI_STOP_SUBSYSTEMS: {
|
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
|
|
|
|
subsystem = spdk_nvmf_subsystem_get_first(g_tgt.tgt);
|
|
|
|
|
|
|
|
if (subsystem) {
|
|
|
|
spdk_nvmf_subsystem_stop(subsystem, nvmf_tgt_subsystem_stopped, NULL);
|
|
|
|
} else {
|
|
|
|
g_tgt.state = NVMF_TGT_FINI_DESTROY_POLL_GROUPS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-11-17 18:43:45 +00:00
|
|
|
case NVMF_TGT_FINI_DESTROY_POLL_GROUPS:
|
|
|
|
/* Send a message to each thread and destroy the poll group */
|
|
|
|
spdk_for_each_thread(nvmf_tgt_destroy_poll_group,
|
|
|
|
NULL,
|
|
|
|
nvmf_tgt_destroy_poll_group_done);
|
2017-11-15 17:48:32 +00:00
|
|
|
break;
|
2017-11-01 23:24:18 +00:00
|
|
|
case NVMF_TGT_FINI_FREE_RESOURCES:
|
|
|
|
spdk_nvmf_tgt_destroy(g_tgt.tgt);
|
|
|
|
g_tgt.state = NVMF_TGT_STOPPED;
|
|
|
|
break;
|
|
|
|
case NVMF_TGT_STOPPED:
|
|
|
|
spdk_app_stop(0);
|
|
|
|
return;
|
|
|
|
case NVMF_TGT_ERROR:
|
|
|
|
spdk_app_stop(rc);
|
|
|
|
return;
|
|
|
|
}
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2017-11-01 23:24:18 +00:00
|
|
|
} while (g_tgt.state != prev_state);
|
2016-06-06 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-04-03 19:56:50 +00:00
|
|
|
spdk_nvmf_tgt_start(struct spdk_app_opts *opts)
|
2016-06-06 21:44:30 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2017-04-03 19:56:50 +00:00
|
|
|
opts->shutdown_cb = spdk_nvmf_shutdown_cb;
|
2016-06-06 21:44:30 +00:00
|
|
|
|
|
|
|
/* Blocks until the application is exiting */
|
2017-11-01 23:24:18 +00:00
|
|
|
rc = spdk_app_start(opts, nvmf_tgt_advance_state, NULL, NULL);
|
2016-06-06 21:44:30 +00:00
|
|
|
|
|
|
|
spdk_app_fini();
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|