example/fio: add option to load json_config

Added new configuration option to bdev fio_plugin
called 'spdk_json_conf'. When provided the SPDK
subsystems are loaded using this JSON configuration.

Only single type of configuration can be provided at
a single time.

While here, added bdev_rpc in Makefile to support all bdev
related RPC that can now be issued via json config.

Change-Id: I5f45fe2d8331034ef4becca43bbaedebd6b20c5a
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463979
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
Tomasz Zawadzki 2019-08-02 07:51:20 -04:00
parent 1a30ba7f25
commit 3f5728fe83
2 changed files with 48 additions and 25 deletions

View File

@ -43,7 +43,7 @@ CFLAGS += -I$(CONFIG_FIO_SOURCE_DIR)
LDFLAGS += -shared -rdynamic -Wl,-z,nodelete LDFLAGS += -shared -rdynamic -Wl,-z,nodelete
SPDK_LIB_LIST = $(ALL_MODULES_LIST) SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += thread util bdev conf copy rpc jsonrpc json log sock trace notify SPDK_LIB_LIST += thread util bdev bdev_rpc conf copy rpc jsonrpc json log sock trace notify
SPDK_LIB_LIST += event event_bdev event_copy event_vmd SPDK_LIB_LIST += event event_bdev event_copy event_vmd
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -59,6 +59,7 @@
struct spdk_fio_options { struct spdk_fio_options {
void *pad; void *pad;
char *conf; char *conf;
char *json_conf;
unsigned mem_mb; unsigned mem_mb;
bool mem_single_seg; bool mem_single_seg;
}; };
@ -89,6 +90,7 @@ struct spdk_fio_thread {
}; };
static bool g_spdk_env_initialized = false; static bool g_spdk_env_initialized = false;
static const char *g_json_config_file = NULL;
static int spdk_fio_init(struct thread_data *td); static int spdk_fio_init(struct thread_data *td);
static void spdk_fio_cleanup(struct thread_data *td); static void spdk_fio_cleanup(struct thread_data *td);
@ -200,8 +202,13 @@ spdk_fio_bdev_init_start(void *arg)
{ {
bool *done = arg; bool *done = arg;
if (g_json_config_file != NULL) {
spdk_app_json_config_load(g_json_config_file, SPDK_DEFAULT_RPC_ADDR,
spdk_fio_bdev_init_done, done);
} else {
spdk_subsystem_init(spdk_fio_bdev_init_done, done); spdk_subsystem_init(spdk_fio_bdev_init_done, done);
} }
}
static void static void
spdk_fio_bdev_fini_done(void *cb_arg) spdk_fio_bdev_fini_done(void *cb_arg)
@ -222,7 +229,7 @@ spdk_init_thread_poll(void *arg)
{ {
struct spdk_fio_options *eo = arg; struct spdk_fio_options *eo = arg;
struct spdk_fio_thread *fio_thread; struct spdk_fio_thread *fio_thread;
struct spdk_conf *config; struct spdk_conf *config = NULL;
struct spdk_env_opts opts; struct spdk_env_opts opts;
bool done; bool done;
int rc; int rc;
@ -235,12 +242,12 @@ spdk_init_thread_poll(void *arg)
/* Parse the SPDK configuration file */ /* Parse the SPDK configuration file */
eo = arg; eo = arg;
if (!eo->conf || !strlen(eo->conf)) {
SPDK_ERRLOG("No configuration file provided\n"); if (eo->conf && eo->json_conf) {
SPDK_ERRLOG("Cannot provide two types of configuration files\n");
rc = EINVAL; rc = EINVAL;
goto err_exit; goto err_exit;
} } else if (eo->conf && strlen(eo->conf)) {
config = spdk_conf_allocate(); config = spdk_conf_allocate();
if (!config) { if (!config) {
SPDK_ERRLOG("Unable to allocate configuration file\n"); SPDK_ERRLOG("Unable to allocate configuration file\n");
@ -261,6 +268,13 @@ spdk_init_thread_poll(void *arg)
goto err_exit; goto err_exit;
} }
spdk_conf_set_as_default(config); spdk_conf_set_as_default(config);
} else if (eo->json_conf && strlen(eo->json_conf)) {
g_json_config_file = eo->json_conf;
} else {
SPDK_ERRLOG("No configuration file provided\n");
rc = EINVAL;
goto err_exit;
}
/* Initialize the environment library */ /* Initialize the environment library */
spdk_env_opts_init(&opts); spdk_env_opts_init(&opts);
@ -702,6 +716,15 @@ static struct fio_option options[] = {
.category = FIO_OPT_C_ENGINE, .category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_INVALID, .group = FIO_OPT_G_INVALID,
}, },
{
.name = "spdk_json_conf",
.lname = "SPDK JSON configuration file",
.type = FIO_OPT_STR_STORE,
.off1 = offsetof(struct spdk_fio_options, json_conf),
.help = "A SPDK JSON configuration file",
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_INVALID,
},
{ {
.name = "spdk_mem", .name = "spdk_mem",
.lname = "SPDK memory in MB", .lname = "SPDK memory in MB",