From 68b9d5838b4f6ee3134f90c3ac5d37a9fc0582f9 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 5 Nov 2018 15:32:19 -0700 Subject: [PATCH] fio_plugin: exit immediately if spdk_fio_init_env fails This is going to be moved to a separate thread later in the patch series and it won't be able to return an error code. The entire program must exit. Change-Id: I718d2a82346f78596f805492392a843e7a79359e Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/432088 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu --- examples/bdev/fio_plugin/fio_plugin.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index d826ec43b..3a9bf7cb5 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -279,25 +279,28 @@ spdk_fio_init_env(struct thread_data *td) eo = td->eo; if (!eo->conf || !strlen(eo->conf)) { SPDK_ERRLOG("No configuration file provided\n"); - return -1; + rc = EINVAL; + goto err_exit; } config = spdk_conf_allocate(); if (!config) { SPDK_ERRLOG("Unable to allocate configuration file\n"); - return -1; + 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); - return -1; + goto err_exit; } if (spdk_conf_first_section(config) == NULL) { SPDK_ERRLOG("Invalid configuration file format\n"); spdk_conf_free(config); - return -1; + rc = EINVAL; + goto err_exit; } spdk_conf_set_as_default(config); @@ -313,7 +316,8 @@ spdk_fio_init_env(struct thread_data *td) if (spdk_env_init(&opts) < 0) { SPDK_ERRLOG("Unable to initialize SPDK env\n"); spdk_conf_free(config); - return -1; + rc = EINVAL; + goto err_exit; } spdk_unaffinitize_thread(); @@ -321,7 +325,7 @@ spdk_fio_init_env(struct thread_data *td) rc = spdk_fio_init_thread(td); if (rc < 0) { SPDK_ERRLOG("Failed to create initialization thread\n"); - return -1; + goto err_exit; } g_init_thread = fio_thread = td->io_ops_data; @@ -356,6 +360,10 @@ spdk_fio_init_env(struct thread_data *td) } return 0; + +err_exit: + exit(rc); + return -1; } /* Called for each thread to fill in the 'real_file_size' member for