reactor: allow spdk_reactors_fini() to be called without prior init

spdk_reactors_fini() is unconditionally called in spdk_app_fini()
at the end of every application and it currently throws a ton
of warning messages if the reactors weren't initialized yet [1].

Let's silence those warnings.

[1] $ spdk_tgt -c invalid.conf
[...]
*WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL!
*WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL!
*WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL!
*WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL!
*WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL!

(Apparently SPDK_ENV_FOREACH_CORE iterates through 128 cores
if the dpdk env framework wasn't initialized. SPDK calls
spdk_reactor_get() on each core and that's what generates the
warnings)

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Change-Id: Ic3a2355ef6d2e0d0e1cc125ba21cc6a802b355bc
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470736
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2019-10-08 09:11:24 +00:00 committed by Jim Harris
parent c4ecc8b876
commit f7ddfcf743

View File

@ -54,7 +54,7 @@
#define SPDK_EVENT_BATCH_SIZE 8 #define SPDK_EVENT_BATCH_SIZE 8
enum spdk_reactor_state { enum spdk_reactor_state {
SPDK_REACTOR_STATE_INVALID = 0, SPDK_REACTOR_STATE_UNINITIALIZED = 0,
SPDK_REACTOR_STATE_INITIALIZED = 1, SPDK_REACTOR_STATE_INITIALIZED = 1,
SPDK_REACTOR_STATE_RUNNING = 2, SPDK_REACTOR_STATE_RUNNING = 2,
SPDK_REACTOR_STATE_EXITING = 3, SPDK_REACTOR_STATE_EXITING = 3,
@ -85,7 +85,7 @@ struct spdk_reactor {
static struct spdk_reactor *g_reactors; static struct spdk_reactor *g_reactors;
static struct spdk_cpuset *g_reactor_core_mask; static struct spdk_cpuset *g_reactor_core_mask;
static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_INVALID; static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_UNINITIALIZED;
static bool g_framework_monitor_context_switch_enabled = true; static bool g_framework_monitor_context_switch_enabled = true;
@ -173,6 +173,10 @@ spdk_reactors_fini(void)
uint32_t i; uint32_t i;
struct spdk_reactor *reactor; struct spdk_reactor *reactor;
if (g_reactor_state == SPDK_REACTOR_STATE_UNINITIALIZED) {
return;
}
spdk_thread_lib_fini(); spdk_thread_lib_fini();
SPDK_ENV_FOREACH_CORE(i) { SPDK_ENV_FOREACH_CORE(i) {