nvmf: Look up bdev channel from poll group instead of namespace
Change-Id: I9afa07b5dae99955ba87d7c8130b2ce6f04e7941 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/389641 Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
d0733ff3b7
commit
e26e0e2689
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user