diff --git a/app/nvmf_tgt/conf.c b/app/nvmf_tgt/conf.c index 9201568a0..8556c6c6a 100644 --- a/app/nvmf_tgt/conf.c +++ b/app/nvmf_tgt/conf.c @@ -125,7 +125,6 @@ spdk_add_nvmf_discovery_subsystem(void) } spdk_nvmf_subsystem_set_allow_any_host(app_subsys->subsystem, true); - nvmf_tgt_start_subsystem(app_subsys); return 0; } @@ -499,8 +498,6 @@ spdk_nvmf_construct_subsystem(const char *name, int32_t lcore, } - nvmf_tgt_start_subsystem(app_subsys); - return 0; error: diff --git a/app/nvmf_tgt/nvmf_tgt.c b/app/nvmf_tgt/nvmf_tgt.c index 14bc8f76c..e28a7e479 100644 --- a/app/nvmf_tgt/nvmf_tgt.c +++ b/app/nvmf_tgt/nvmf_tgt.c @@ -55,48 +55,17 @@ static size_t g_active_poll_groups = 0; static struct spdk_poller *g_acceptor_poller = NULL; static TAILQ_HEAD(, nvmf_tgt_subsystem) g_subsystems = TAILQ_HEAD_INITIALIZER(g_subsystems); -static bool g_subsystems_shutdown; static void nvmf_tgt_advance_state(void *arg1, void *arg2); -static void -subsystem_delete_event(void *arg1, void *arg2) -{ - struct nvmf_tgt_subsystem *app_subsys = arg1; - struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem; - - TAILQ_REMOVE(&g_subsystems, app_subsys, tailq); - free(app_subsys); - - spdk_nvmf_delete_subsystem(subsystem); - - if (g_subsystems_shutdown && TAILQ_EMPTY(&g_subsystems)) { - g_tgt.state = NVMF_TGT_FINI_FREE_RESOURCES; - nvmf_tgt_advance_state(NULL, NULL); - } -} - -static void -subsystem_stop(void *arg1, void *arg2) -{ - struct nvmf_tgt_subsystem *app_subsys = arg1; - struct spdk_event *event = arg2; - - spdk_nvmf_subsystem_stop(app_subsys->subsystem); - - spdk_event_call(event); -} - static void nvmf_tgt_delete_subsystem(struct nvmf_tgt_subsystem *app_subsys) { - struct spdk_event *event1, *event2; + TAILQ_REMOVE(&g_subsystems, app_subsys, tailq); - event2 = spdk_event_allocate(spdk_env_get_current_core(), subsystem_delete_event, - app_subsys, NULL); - event1 = spdk_event_allocate(app_subsys->lcore, subsystem_stop, app_subsys, event2); + spdk_nvmf_delete_subsystem(app_subsys->subsystem); - spdk_event_call(event1); + free(app_subsys); } static void @@ -110,25 +79,6 @@ spdk_nvmf_shutdown_cb(void) nvmf_tgt_advance_state(NULL, NULL); } -static void -_nvmf_tgt_start_subsystem(void *arg1, void *arg2) -{ - struct nvmf_tgt_subsystem *app_subsys = arg1; - struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem; - - spdk_nvmf_subsystem_start(subsystem); -} - -void -nvmf_tgt_start_subsystem(struct nvmf_tgt_subsystem *app_subsys) -{ - struct spdk_event *event; - - event = spdk_event_allocate(app_subsys->lcore, _nvmf_tgt_start_subsystem, - app_subsys, NULL); - spdk_event_call(event); -} - struct nvmf_tgt_subsystem * nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype, uint32_t num_ns, uint32_t lcore) @@ -314,10 +264,10 @@ nvmf_tgt_advance_state(void *arg1, void *arg2) case NVMF_TGT_FINI_SHUTDOWN_SUBSYSTEMS: { struct nvmf_tgt_subsystem *app_subsys, *tmp; - g_subsystems_shutdown = true; TAILQ_FOREACH_SAFE(app_subsys, &g_subsystems, tailq, tmp) { nvmf_tgt_delete_subsystem(app_subsys); } + g_tgt.state = NVMF_TGT_FINI_FREE_RESOURCES; break; } case NVMF_TGT_FINI_FREE_RESOURCES: diff --git a/app/nvmf_tgt/nvmf_tgt.h b/app/nvmf_tgt/nvmf_tgt.h index 8c9081097..84563bce0 100644 --- a/app/nvmf_tgt/nvmf_tgt.h +++ b/app/nvmf_tgt/nvmf_tgt.h @@ -91,8 +91,6 @@ nvmf_tgt_subsystem_next(struct nvmf_tgt_subsystem *subsystem); int spdk_nvmf_parse_conf(void); -void nvmf_tgt_start_subsystem(struct nvmf_tgt_subsystem *subsystem); - struct nvmf_tgt_subsystem *nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype, uint32_t num_ns, uint32_t lcore); diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index ecf4611e9..13273fc97 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -139,15 +139,6 @@ struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(struct spdk_nvmf_tgt *tgt struct spdk_nvmf_subsystem *spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn); -/** - * Initialize the subsystem on the thread that will be used to poll it. - * - * \param subsystem Subsystem that will be polled on this core. - */ -int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem); - -void spdk_nvmf_subsystem_stop(struct spdk_nvmf_subsystem *subsystem); - void spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem); /** diff --git a/lib/nvmf/ctrlr_bdev.c b/lib/nvmf/ctrlr_bdev.c index b2ac7cf59..b9532f5ef 100644 --- a/lib/nvmf/ctrlr_bdev.c +++ b/lib/nvmf/ctrlr_bdev.c @@ -380,6 +380,7 @@ spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) struct spdk_bdev *bdev; struct spdk_bdev_desc *desc; struct spdk_io_channel *ch; + struct spdk_nvmf_poll_group *group = req->qpair->group; struct spdk_nvmf_subsystem *subsystem = req->qpair->ctrlr->subsys; struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl; @@ -397,7 +398,7 @@ spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) bdev = ns->bdev; desc = ns->desc; - ch = ns->ch; + ch = group->sgroups[subsystem->id].channels[nsid - 1]; switch (cmd->opc) { case SPDK_NVME_OPC_READ: return nvmf_bdev_ctrlr_read_cmd(bdev, desc, ch, req); @@ -413,64 +414,3 @@ spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) return nvmf_bdev_ctrlr_nvme_passthru_io(bdev, desc, ch, req); } } - -static int -spdk_nvmf_ns_bdev_attach(struct spdk_nvmf_ns *ns) -{ - if (ns->bdev == NULL) { - return 0; - } - - ns->ch = spdk_bdev_get_io_channel(ns->desc); - if (ns->ch == NULL) { - SPDK_ERRLOG("io_channel allocation failed\n"); - return -1; - } - - return 0; -} - -static void -spdk_nvmf_ns_bdev_detach(struct spdk_nvmf_ns *ns) -{ - if (ns->bdev == NULL) { - return; - } - - if (ns->ch) { - spdk_put_io_channel(ns->ch); - ns->ch = NULL; - } - if (ns->desc) { - spdk_bdev_close(ns->desc); - ns->desc = NULL; - } - ns->bdev = NULL; -} - -int -spdk_nvmf_subsystem_bdev_attach(struct spdk_nvmf_subsystem *subsystem) -{ - struct spdk_nvmf_ns *ns; - - for (ns = spdk_nvmf_subsystem_get_first_ns(subsystem); ns != NULL; - ns = spdk_nvmf_subsystem_get_next_ns(subsystem, ns)) { - if (spdk_nvmf_ns_bdev_attach(ns)) { - return -1; - } - } - - return 0; -} - -void -spdk_nvmf_subsystem_bdev_detach(struct spdk_nvmf_subsystem *subsystem) -{ - struct spdk_nvmf_ns *ns; - - for (ns = spdk_nvmf_subsystem_get_first_ns(subsystem); ns != NULL; - ns = spdk_nvmf_subsystem_get_next_ns(subsystem, ns)) { - spdk_nvmf_ns_bdev_detach(ns); - } - subsystem->max_nsid = 0; -} diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 8abdcc5c5..ea8dbc84b 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -127,7 +127,6 @@ struct spdk_nvmf_request { struct spdk_nvmf_ns { struct spdk_bdev *bdev; struct spdk_bdev_desc *desc; - struct spdk_io_channel *ch; uint32_t id; bool allocated; }; @@ -240,8 +239,6 @@ bool spdk_nvmf_ctrlr_write_zeroes_supported(struct spdk_nvmf_ctrlr *ctrlr); int spdk_nvmf_bdev_ctrlr_identify_ns(struct spdk_bdev *bdev, struct spdk_nvme_ns_data *nsdata); -int spdk_nvmf_subsystem_bdev_attach(struct spdk_nvmf_subsystem *subsystem); -void spdk_nvmf_subsystem_bdev_detach(struct spdk_nvmf_subsystem *subsystem); int spdk_nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_ctrlr *ctrlr); void spdk_nvmf_subsystem_remove_ctrlr(struct spdk_nvmf_subsystem *subsystem, diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 588b29aa7..219271371 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -44,18 +44,6 @@ #include "spdk_internal/bdev.h" #include "spdk_internal/log.h" -int -spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem) -{ - return spdk_nvmf_subsystem_bdev_attach(subsystem); -} - -void -spdk_nvmf_subsystem_stop(struct spdk_nvmf_subsystem *subsystem) -{ - spdk_nvmf_subsystem_bdev_detach(subsystem); -} - static bool spdk_nvmf_valid_nqn(const char *nqn) { diff --git a/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c b/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c index a785f5104..aede115c5 100644 --- a/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c +++ b/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c @@ -144,17 +144,6 @@ spdk_nvmf_poll_group_add_ns(struct spdk_nvmf_poll_group *group, return 0; } -int -spdk_nvmf_subsystem_bdev_attach(struct spdk_nvmf_subsystem *subsystem) -{ - return -1; -} - -void -spdk_nvmf_subsystem_bdev_detach(struct spdk_nvmf_subsystem *subsystem) -{ -} - static bool all_zero(const void *buf, size_t size) { diff --git a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c index 6a4e9e48b..1dbadd4bf 100644 --- a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c @@ -39,17 +39,6 @@ SPDK_LOG_REGISTER_TRACE_FLAG("nvmf", SPDK_TRACE_NVMF) -int -spdk_nvmf_subsystem_bdev_attach(struct spdk_nvmf_subsystem *subsystem) -{ - return -1; -} - -void -spdk_nvmf_subsystem_bdev_detach(struct spdk_nvmf_subsystem *subsystem) -{ -} - int spdk_nvmf_transport_listen(struct spdk_nvmf_transport *transport, const struct spdk_nvme_transport_id *trid)