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
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
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -59,6 +59,7 @@
struct spdk_fio_options {
void *pad;
char *conf;
char *json_conf;
unsigned mem_mb;
bool mem_single_seg;
};
@ -89,6 +90,7 @@ struct spdk_fio_thread {
};
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 void spdk_fio_cleanup(struct thread_data *td);
@ -200,7 +202,12 @@ spdk_fio_bdev_init_start(void *arg)
{
bool *done = arg;
spdk_subsystem_init(spdk_fio_bdev_init_done, done);
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);
}
}
static void
@ -222,7 +229,7 @@ spdk_init_thread_poll(void *arg)
{
struct spdk_fio_options *eo = arg;
struct spdk_fio_thread *fio_thread;
struct spdk_conf *config;
struct spdk_conf *config = NULL;
struct spdk_env_opts opts;
bool done;
int rc;
@ -235,33 +242,40 @@ spdk_init_thread_poll(void *arg)
/* Parse the SPDK configuration file */
eo = arg;
if (!eo->conf || !strlen(eo->conf)) {
if (eo->conf && eo->json_conf) {
SPDK_ERRLOG("Cannot provide two types of configuration files\n");
rc = EINVAL;
goto err_exit;
} else if (eo->conf && strlen(eo->conf)) {
config = spdk_conf_allocate();
if (!config) {
SPDK_ERRLOG("Unable to allocate configuration file\n");
rc = ENOMEM;
goto err_exit;
}
rc = spdk_conf_read(config, eo->conf);
if (rc != 0) {
SPDK_ERRLOG("Invalid configuration file format\n");
spdk_conf_free(config);
goto err_exit;
}
if (spdk_conf_first_section(config) == NULL) {
SPDK_ERRLOG("Invalid configuration file format\n");
spdk_conf_free(config);
rc = EINVAL;
goto err_exit;
}
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;
}
config = spdk_conf_allocate();
if (!config) {
SPDK_ERRLOG("Unable to allocate configuration file\n");
rc = ENOMEM;
goto err_exit;
}
rc = spdk_conf_read(config, eo->conf);
if (rc != 0) {
SPDK_ERRLOG("Invalid configuration file format\n");
spdk_conf_free(config);
goto err_exit;
}
if (spdk_conf_first_section(config) == NULL) {
SPDK_ERRLOG("Invalid configuration file format\n");
spdk_conf_free(config);
rc = EINVAL;
goto err_exit;
}
spdk_conf_set_as_default(config);
/* Initialize the environment library */
spdk_env_opts_init(&opts);
opts.name = "fio";
@ -702,6 +716,15 @@ static struct fio_option options[] = {
.category = FIO_OPT_C_ENGINE,
.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",
.lname = "SPDK memory in MB",