nvmf: move io_channel allocation to virtual.c
Change-Id: Ibe0464a539b7545d7f911d6af13a1bd3f7bd3cd9 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
8e632c0722
commit
cc85d7ef68
@ -47,7 +47,6 @@
|
||||
#include "spdk/event.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/io_channel.h"
|
||||
|
||||
#define SPDK_NVMF_BUILD_ETC "/usr/local/etc/nvmf"
|
||||
#define SPDK_NVMF_DEFAULT_CONFIG SPDK_NVMF_BUILD_ETC "/nvmf.conf"
|
||||
@ -177,20 +176,9 @@ _nvmf_tgt_start_subsystem(void *arg1, void *arg2)
|
||||
{
|
||||
struct nvmf_tgt_subsystem *app_subsys = arg1;
|
||||
struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem;
|
||||
struct spdk_bdev *bdev;
|
||||
struct spdk_io_channel *ch;
|
||||
int lcore = spdk_app_get_current_core();
|
||||
int i;
|
||||
|
||||
if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME &&
|
||||
subsystem->mode == NVMF_SUBSYSTEM_MODE_VIRTUAL) {
|
||||
for (i = 0; i < subsystem->dev.virt.ns_count; i++) {
|
||||
bdev = subsystem->dev.virt.ns_list[i];
|
||||
ch = spdk_bdev_get_io_channel(bdev, SPDK_IO_PRIORITY_DEFAULT);
|
||||
assert(ch != NULL);
|
||||
subsystem->dev.virt.ch[i] = ch;
|
||||
}
|
||||
}
|
||||
spdk_nvmf_subsystem_start(subsystem);
|
||||
|
||||
spdk_poller_register(&app_subsys->poller, subsystem_poll, app_subsys, lcore, 0);
|
||||
}
|
||||
|
@ -84,6 +84,11 @@ struct spdk_nvmf_host {
|
||||
};
|
||||
|
||||
struct spdk_nvmf_ctrlr_ops {
|
||||
/**
|
||||
* Initialize the controller.
|
||||
*/
|
||||
int (*attach)(struct spdk_nvmf_subsystem *subsystem);
|
||||
|
||||
/**
|
||||
* Set NVMe ctrlr AER.
|
||||
*/
|
||||
@ -165,6 +170,13 @@ struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(const char *nqn,
|
||||
spdk_nvmf_subsystem_connect_fn connect_cb,
|
||||
spdk_nvmf_subsystem_disconnect_fn disconnect_cb);
|
||||
|
||||
/**
|
||||
* 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_delete_subsystem(struct spdk_nvmf_subsystem *subsystem);
|
||||
|
||||
struct spdk_nvmf_subsystem *
|
||||
|
@ -261,6 +261,12 @@ nvmf_direct_ctrlr_complete_aer(void *arg, const struct spdk_nvme_cpl *cpl)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
nvmf_direct_ctrlr_attach(struct spdk_nvmf_subsystem *subsystem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_direct_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys)
|
||||
{
|
||||
@ -269,6 +275,7 @@ nvmf_direct_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys)
|
||||
}
|
||||
|
||||
const struct spdk_nvmf_ctrlr_ops spdk_nvmf_direct_ctrlr_ops = {
|
||||
.attach = nvmf_direct_ctrlr_attach,
|
||||
.set_aer_callback = nvmf_direct_ctrlr_set_aer_callback,
|
||||
.ctrlr_get_data = nvmf_direct_ctrlr_get_data,
|
||||
.process_admin_cmd = nvmf_direct_ctrlr_process_admin_cmd,
|
||||
|
@ -122,6 +122,16 @@ spdk_nvmf_subsystem_host_allowed(struct spdk_nvmf_subsystem *subsystem, const ch
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem)
|
||||
{
|
||||
if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME) {
|
||||
return subsystem->ops->attach(subsystem);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_nvmf_subsystem_poll(struct spdk_nvmf_subsystem *subsystem)
|
||||
{
|
||||
|
@ -520,6 +520,26 @@ nvmf_virtual_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
nvmf_virtual_ctrlr_attach(struct spdk_nvmf_subsystem *subsystem)
|
||||
{
|
||||
struct spdk_bdev *bdev;
|
||||
struct spdk_io_channel *ch;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < subsystem->dev.virt.ns_count; i++) {
|
||||
bdev = subsystem->dev.virt.ns_list[i];
|
||||
ch = spdk_bdev_get_io_channel(bdev, SPDK_IO_PRIORITY_DEFAULT);
|
||||
if (ch == NULL) {
|
||||
SPDK_ERRLOG("io_channel allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
subsystem->dev.virt.ch[i] = ch;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_virtual_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem)
|
||||
{
|
||||
@ -542,6 +562,7 @@ nvmf_virtual_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys)
|
||||
}
|
||||
|
||||
const struct spdk_nvmf_ctrlr_ops spdk_nvmf_virtual_ctrlr_ops = {
|
||||
.attach = nvmf_virtual_ctrlr_attach,
|
||||
.set_aer_callback = nvmf_virtual_ctrlr_set_aer_callback,
|
||||
.ctrlr_get_data = nvmf_virtual_ctrlr_get_data,
|
||||
.process_admin_cmd = nvmf_virtual_ctrlr_process_admin_cmd,
|
||||
|
@ -100,6 +100,12 @@ spdk_nvmf_request_complete(struct spdk_nvmf_request *req)
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct spdk_io_channel *
|
||||
spdk_bdev_get_io_channel(struct spdk_bdev *bdev, uint32_t priority)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spdk_bdev_io *spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
||||
uint64_t offset, uint64_t length, spdk_bdev_io_completion_cb cb, void *cb_arg)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user