diff --git a/app/iscsi_tgt/Makefile b/app/iscsi_tgt/Makefile index 31a273610..a5b38e90f 100644 --- a/app/iscsi_tgt/Makefile +++ b/app/iscsi_tgt/Makefile @@ -43,7 +43,7 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/lib C_SRCS := iscsi_tgt.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_iscsi event_net +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_iscsi event_net ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV)) SPDK_LIB_LIST += env_dpdk_rpc diff --git a/app/nvmf_tgt/Makefile b/app/nvmf_tgt/Makefile index a27d57ac5..282f0fe7e 100644 --- a/app/nvmf_tgt/Makefile +++ b/app/nvmf_tgt/Makefile @@ -39,7 +39,7 @@ APP = nvmf_tgt C_SRCS := nvmf_main.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_nvmf +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_nvmf ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV)) SPDK_LIB_LIST += env_dpdk_rpc diff --git a/app/spdk_dd/Makefile b/app/spdk_dd/Makefile index f2b614dd5..e302c12f5 100644 --- a/app/spdk_dd/Makefile +++ b/app/spdk_dd/Makefile @@ -39,6 +39,6 @@ APP = spdk_dd C_SRCS := spdk_dd.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/app/spdk_tgt/Makefile b/app/spdk_tgt/Makefile index 91d590aa7..627cfe269 100644 --- a/app/spdk_tgt/Makefile +++ b/app/spdk_tgt/Makefile @@ -41,7 +41,7 @@ C_SRCS := spdk_tgt.c SPDK_LIB_LIST = $(ALL_MODULES_LIST) -SPDK_LIB_LIST += event_iscsi event_nvmf +SPDK_LIB_LIST += event event_iscsi event_nvmf ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV)) SPDK_LIB_LIST += env_dpdk_rpc diff --git a/app/vhost/Makefile b/app/vhost/Makefile index 7df6b0a9b..e6b6c2def 100644 --- a/app/vhost/Makefile +++ b/app/vhost/Makefile @@ -39,7 +39,7 @@ APP = vhost C_SRCS := vhost.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_vhost event_nbd +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_vhost event_nbd ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV)) SPDK_LIB_LIST += env_dpdk_rpc diff --git a/examples/accel/perf/Makefile b/examples/accel/perf/Makefile index 53b9ae6cb..f1983d98f 100644 --- a/examples/accel/perf/Makefile +++ b/examples/accel/perf/Makefile @@ -39,6 +39,6 @@ APP = accel_perf C_SRCS := accel_perf.c -SPDK_LIB_LIST = $(ACCEL_MODULES_LIST) event_accel +SPDK_LIB_LIST = $(ACCEL_MODULES_LIST) event event_accel include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/examples/bdev/fio_plugin/Makefile b/examples/bdev/fio_plugin/Makefile index 1d48d1e99..b93456651 100644 --- a/examples/bdev/fio_plugin/Makefile +++ b/examples/bdev/fio_plugin/Makefile @@ -40,6 +40,6 @@ FIO_PLUGIN := spdk_bdev C_SRCS = fio_plugin.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev include $(SPDK_ROOT_DIR)/mk/spdk.fio.mk diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 2ce5c8104..483664f99 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -43,6 +43,7 @@ #include "spdk/queue.h" #include "spdk/util.h" +#include "spdk_internal/init.h" #include "spdk_internal/event.h" #include "config-host.h" diff --git a/examples/bdev/hello_world/Makefile b/examples/bdev/hello_world/Makefile index e2848a7ce..ae413fdf3 100644 --- a/examples/bdev/hello_world/Makefile +++ b/examples/bdev/hello_world/Makefile @@ -37,6 +37,6 @@ APP = hello_bdev C_SRCS := hello_bdev.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/examples/blob/cli/Makefile b/examples/blob/cli/Makefile index e658ebc87..e072ca6d7 100644 --- a/examples/blob/cli/Makefile +++ b/examples/blob/cli/Makefile @@ -38,6 +38,6 @@ APP = blobcli C_SRCS := blobcli.c # Don't link bdev_lvol in blobcli - otherwise this utility cannot operate on an lvolstore -SPDK_LIB_LIST = $(filter-out bdev_lvol,$(ALL_MODULES_LIST)) event_bdev +SPDK_LIB_LIST = $(filter-out bdev_lvol,$(ALL_MODULES_LIST)) event event_bdev include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/examples/blob/hello_world/Makefile b/examples/blob/hello_world/Makefile index ad6c814cc..a93d47755 100644 --- a/examples/blob/hello_world/Makefile +++ b/examples/blob/hello_world/Makefile @@ -37,6 +37,6 @@ APP = hello_blob C_SRCS := hello_blob.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/examples/interrupt_tgt/Makefile b/examples/interrupt_tgt/Makefile index 90a2b8a4d..e84eb4509 100644 --- a/examples/interrupt_tgt/Makefile +++ b/examples/interrupt_tgt/Makefile @@ -39,7 +39,7 @@ APP = interrupt_tgt C_SRCS := interrupt_tgt.c -SPDK_LIB_LIST = $(INTR_BLOCKDEV_MODULES_LIST) event_bdev conf +SPDK_LIB_LIST = $(INTR_BLOCKDEV_MODULES_LIST) event event_bdev conf SPDK_LIB_LIST += event_nbd SPDK_LIB_LIST += event_vhost diff --git a/examples/nvmf/nvmf/Makefile b/examples/nvmf/nvmf/Makefile index 4db21ca82..d83d278cc 100644 --- a/examples/nvmf/nvmf/Makefile +++ b/examples/nvmf/nvmf/Makefile @@ -38,6 +38,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk APP := nvmf C_SRCS := nvmf.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev nvmf +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev nvmf include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/examples/nvmf/nvmf/nvmf.c b/examples/nvmf/nvmf/nvmf.c index 8f7170980..5e77e1683 100644 --- a/examples/nvmf/nvmf/nvmf.c +++ b/examples/nvmf/nvmf/nvmf.c @@ -42,6 +42,7 @@ #include "spdk/likely.h" #include "spdk_internal/event.h" +#include "spdk_internal/init.h" #define NVMF_DEFAULT_SUBSYSTEMS 32 #define ACCEPT_TIMEOUT_US 10000 /* 10ms */ diff --git a/examples/sock/hello_world/Makefile b/examples/sock/hello_world/Makefile index f86df44cc..350c30570 100644 --- a/examples/sock/hello_world/Makefile +++ b/examples/sock/hello_world/Makefile @@ -38,6 +38,6 @@ APP = hello_sock C_SRCS := hello_sock.c SPDK_LIB_LIST = $(SOCK_MODULES_LIST) -SPDK_LIB_LIST += event_net sock +SPDK_LIB_LIST += event event_net sock include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index 9ecc4209d..73c2bf5c0 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -164,56 +164,12 @@ int spdk_reactor_set_interrupt_mode(uint32_t lcore, bool new_in_interrupt, */ struct spdk_thread *_spdk_get_app_thread(void); -struct spdk_subsystem { - const char *name; - /* User must call spdk_subsystem_init_next() when they are done with their initialization. */ - void (*init)(void); - void (*fini)(void); +typedef void (*spdk_app_init_fn)(int rc, void *ctx); - /** - * Write JSON configuration handler. - * - * \param w JSON write context - */ - void (*write_config_json)(struct spdk_json_write_ctx *w); - TAILQ_ENTRY(spdk_subsystem) tailq; -}; - -struct spdk_subsystem *spdk_subsystem_find(const char *name); -struct spdk_subsystem *spdk_subsystem_get_first(void); -struct spdk_subsystem *spdk_subsystem_get_next(struct spdk_subsystem *cur_subsystem); - -struct spdk_subsystem_depend { - const char *name; - const char *depends_on; - TAILQ_ENTRY(spdk_subsystem_depend) tailq; -}; - -struct spdk_subsystem_depend *spdk_subsystem_get_first_depend(void); -struct spdk_subsystem_depend *spdk_subsystem_get_next_depend(struct spdk_subsystem_depend - *cur_depend); - -void spdk_add_subsystem(struct spdk_subsystem *subsystem); -void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend); - -typedef void (*spdk_subsystem_init_fn)(int rc, void *ctx); -void spdk_subsystem_init(spdk_subsystem_init_fn cb_fn, void *cb_arg); -void spdk_subsystem_fini(spdk_msg_fn cb_fn, void *cb_arg); -void spdk_subsystem_init_next(int rc); -void spdk_subsystem_fini_next(void); void spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr, - spdk_subsystem_init_fn cb_fn, void *cb_arg, + spdk_app_init_fn cb_fn, void *cb_arg, bool stop_on_error); -/** - * Save pointed \c subsystem configuration to the JSON write context \c w. In case of - * error \c null is written to the JSON context. - * - * \param w JSON write context - * \param subsystem the subsystem to query - */ -void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem); - int spdk_rpc_initialize(const char *listen_addr); void spdk_rpc_finish(void); diff --git a/include/spdk_internal/init.h b/include/spdk_internal/init.h new file mode 100644 index 000000000..67fd6cd53 --- /dev/null +++ b/include/spdk_internal/init.h @@ -0,0 +1,125 @@ +/*- + * BSD LICENSE + * + * Copyright (c) Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * \file + * SPDK Initialization Helper + */ + +#ifndef SPDK_INIT_H +#define SPDK_INIT_H + +#include "spdk/stdinc.h" +#include "spdk/queue.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct spdk_json_write_ctx; + +struct spdk_subsystem { + const char *name; + /* User must call spdk_subsystem_init_next() when they are done with their initialization. */ + void (*init)(void); + void (*fini)(void); + + /** + * Write JSON configuration handler. + * + * \param w JSON write context + */ + void (*write_config_json)(struct spdk_json_write_ctx *w); + TAILQ_ENTRY(spdk_subsystem) tailq; +}; + +struct spdk_subsystem *spdk_subsystem_find(const char *name); +struct spdk_subsystem *spdk_subsystem_get_first(void); +struct spdk_subsystem *spdk_subsystem_get_next(struct spdk_subsystem *cur_subsystem); + +struct spdk_subsystem_depend { + const char *name; + const char *depends_on; + TAILQ_ENTRY(spdk_subsystem_depend) tailq; +}; + +struct spdk_subsystem_depend *spdk_subsystem_get_first_depend(void); +struct spdk_subsystem_depend *spdk_subsystem_get_next_depend(struct spdk_subsystem_depend + *cur_depend); + +void spdk_add_subsystem(struct spdk_subsystem *subsystem); +void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend); + +typedef void (*spdk_subsystem_init_fn)(int rc, void *ctx); +void spdk_subsystem_init(spdk_subsystem_init_fn cb_fn, void *cb_arg); + +typedef void (*spdk_subsystem_fini_fn)(void *ctx); +void spdk_subsystem_fini(spdk_subsystem_fini_fn cb_fn, void *cb_arg); +void spdk_subsystem_init_next(int rc); +void spdk_subsystem_fini_next(void); + +/** + * Save pointed \c subsystem configuration to the JSON write context \c w. In case of + * error \c null is written to the JSON context. + * + * \param w JSON write context + * \param subsystem the subsystem to query + */ +void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem); + +/** + * \brief Register a new subsystem + */ +#define SPDK_SUBSYSTEM_REGISTER(_name) \ + __attribute__((constructor)) static void _name ## _register(void) \ + { \ + spdk_add_subsystem(&_name); \ + } + +/** + * \brief Declare that a subsystem depends on another subsystem. + */ +#define SPDK_SUBSYSTEM_DEPEND(_name, _depends_on) \ + static struct spdk_subsystem_depend __subsystem_ ## _name ## _depend_on ## _depends_on = { \ + .name = #_name, \ + .depends_on = #_depends_on, \ + }; \ + __attribute__((constructor)) static void _name ## _depend_on ## _depends_on(void) \ + { \ + spdk_add_subsystem_depend(&__subsystem_ ## _name ## _depend_on ## _depends_on); \ + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/Makefile b/lib/Makefile index eab297ed0..58b0017b9 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.lib_deps.mk DIRS-y += bdev blob blobfs conf accel event json jsonrpc \ log lvol net rpc sock thread trace util nvme vmd nvmf scsi \ - ioat ut_mock iscsi notify + ioat ut_mock iscsi notify init ifeq ($(OS),Linux) DIRS-y += nbd ftl endif diff --git a/lib/event/Makefile b/lib/event/Makefile index 359bfe81f..5cd155870 100644 --- a/lib/event/Makefile +++ b/lib/event/Makefile @@ -34,14 +34,14 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk -SO_VER := 8 +SO_VER := 9 SO_MINOR := 0 CFLAGS += $(ENV_CFLAGS) LIBNAME = event -C_SRCS = app.c reactor.c rpc.c subsystem.c json_config.c log_rpc.c \ - app_rpc.c subsystem_rpc.c scheduler_static.c +C_SRCS = app.c reactor.c rpc.c json_config.c log_rpc.c \ + app_rpc.c scheduler_static.c # Do not compile schedulers and governors based on DPDK env # if non-DPDK env is used. diff --git a/lib/event/app.c b/lib/event/app.c index 3eb31da30..7ef66832a 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -35,6 +35,7 @@ #include "spdk/version.h" #include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "spdk/assert.h" #include "spdk/env.h" diff --git a/lib/event/json_config.c b/lib/event/json_config.c index da085846a..e42f30581 100644 --- a/lib/event/json_config.c +++ b/lib/event/json_config.c @@ -42,6 +42,7 @@ #include "spdk/rpc.h" #include "spdk_internal/event.h" +#include "spdk_internal/init.h" #define SPDK_DEBUG_APP_CFG(...) SPDK_DEBUGLOG(app_config, __VA_ARGS__) @@ -85,7 +86,7 @@ typedef void (*client_resp_handler)(struct load_json_config_ctx *, struct load_json_config_ctx { /* Thread used during configuration. */ struct spdk_thread *thread; - spdk_subsystem_init_fn cb_fn; + spdk_app_init_fn cb_fn; void *cb_arg; bool stop_on_error; @@ -567,7 +568,7 @@ err: void spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr, - spdk_subsystem_init_fn cb_fn, void *cb_arg, + spdk_app_init_fn cb_fn, void *cb_arg, bool stop_on_error) { struct load_json_config_ctx *ctx = calloc(1, sizeof(*ctx)); diff --git a/lib/event/spdk_event.map b/lib/event/spdk_event.map index 9a4ba5603..146dc29c4 100644 --- a/lib/event/spdk_event.map +++ b/lib/event/spdk_event.map @@ -25,19 +25,7 @@ spdk_reactor_get; spdk_for_each_reactor; spdk_reactor_set_interrupt_mode; - spdk_subsystem_find; - spdk_subsystem_get_first; - spdk_subsystem_get_next; - spdk_subsystem_get_first_depend; - spdk_subsystem_get_next_depend; - spdk_add_subsystem; - spdk_add_subsystem_depend; - spdk_subsystem_init; - spdk_subsystem_fini; - spdk_subsystem_init_next; - spdk_subsystem_fini_next; spdk_app_json_config_load; - spdk_subsystem_config_json; spdk_rpc_initialize; spdk_rpc_finish; diff --git a/lib/init/Makefile b/lib/init/Makefile new file mode 100644 index 000000000..8cd598c06 --- /dev/null +++ b/lib/init/Makefile @@ -0,0 +1,45 @@ +# +# BSD LICENSE +# +# Copyright (c) Intel Corporation. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) +include $(SPDK_ROOT_DIR)/mk/spdk.common.mk + +SO_VER := 1 +SO_MINOR := 0 + +C_SRCS = subsystem.c subsystem_rpc.c +LIBNAME = init + +SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_init.map) + +include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk diff --git a/lib/init/spdk_init.map b/lib/init/spdk_init.map new file mode 100644 index 000000000..2aa5b3dff --- /dev/null +++ b/lib/init/spdk_init.map @@ -0,0 +1,19 @@ +{ + global: + + # Public functions + spdk_subsystem_find; + spdk_subsystem_get_first; + spdk_subsystem_get_next; + spdk_subsystem_get_first_depend; + spdk_subsystem_get_next_depend; + spdk_add_subsystem; + spdk_add_subsystem_depend; + spdk_subsystem_init; + spdk_subsystem_fini; + spdk_subsystem_init_next; + spdk_subsystem_fini_next; + spdk_subsystem_config_json; + + local: *; +}; diff --git a/lib/event/subsystem.c b/lib/init/subsystem.c similarity index 99% rename from lib/event/subsystem.c rename to lib/init/subsystem.c index a4f7092ea..a1475ded5 100644 --- a/lib/event/subsystem.c +++ b/lib/init/subsystem.c @@ -36,9 +36,11 @@ #include "spdk/log.h" #include "spdk/thread.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "spdk/env.h" +#include "spdk/json.h" + TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem); struct spdk_subsystem_list g_subsystems = TAILQ_HEAD_INITIALIZER(g_subsystems); diff --git a/lib/event/subsystem_rpc.c b/lib/init/subsystem_rpc.c similarity index 99% rename from lib/event/subsystem_rpc.c rename to lib/init/subsystem_rpc.c index 293493afa..cfee3e593 100644 --- a/lib/event/subsystem_rpc.c +++ b/lib/init/subsystem_rpc.c @@ -31,12 +31,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "spdk_internal/event.h" #include "spdk/rpc.h" #include "spdk/string.h" #include "spdk/util.h" #include "spdk/env.h" +#include "spdk_internal/init.h" + static void rpc_framework_get_subsystems(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params) diff --git a/mk/spdk.lib_deps.mk b/mk/spdk.lib_deps.mk index 7b2912e06..e45ddba03 100644 --- a/mk/spdk.lib_deps.mk +++ b/mk/spdk.lib_deps.mk @@ -83,7 +83,8 @@ DEPDIRS-trace := log util $(JSON_LIBS) DEPDIRS-bdev := log util thread $(JSON_LIBS) notify trace DEPDIRS-blobfs := log thread blob trace -DEPDIRS-event := log util thread $(JSON_LIBS) trace +DEPDIRS-event := log util thread $(JSON_LIBS) trace init +DEPDIRS-init := jsonrpc json log rpc thread DEPDIRS-ftl := log util thread trace bdev DEPDIRS-nbd := log util thread $(JSON_LIBS) bdev @@ -159,16 +160,16 @@ endif # These depdirs include subsystem interdependencies which # are not related to symbols, but are defined directly in # the SPDK event subsystem code. -DEPDIRS-event_accel := event accel -DEPDIRS-event_net := event net -DEPDIRS-event_vmd := event vmd $(JSON_LIBS) log thread +DEPDIRS-event_accel := init accel +DEPDIRS-event_net := init net +DEPDIRS-event_vmd := init vmd $(JSON_LIBS) log thread -DEPDIRS-event_bdev := event bdev event_accel event_vmd event_sock +DEPDIRS-event_bdev := init bdev event_accel event_vmd event_sock -DEPDIRS-event_nbd := event nbd event_bdev -DEPDIRS-event_nvmf := event nvmf event_bdev event_sock thread log bdev $(JSON_LIBS) -DEPDIRS-event_scsi := event scsi event_bdev +DEPDIRS-event_nbd := init nbd event_bdev +DEPDIRS-event_nvmf := init nvmf event_bdev event_sock thread log bdev $(JSON_LIBS) +DEPDIRS-event_scsi := init scsi event_bdev -DEPDIRS-event_iscsi := event iscsi event_scsi event_sock -DEPDIRS-event_vhost := event vhost event_scsi -DEPDIRS-event_sock := event sock +DEPDIRS-event_iscsi := init iscsi event_scsi event_sock +DEPDIRS-event_vhost := init vhost event_scsi +DEPDIRS-event_sock := init sock diff --git a/module/event/subsystems/accel/accel.c b/module/event/subsystems/accel/accel.c index dd20c3b22..079cac9a6 100644 --- a/module/event/subsystems/accel/accel.c +++ b/module/event/subsystems/accel/accel.c @@ -35,7 +35,7 @@ #include "spdk/accel_engine.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "spdk/env.h" static void diff --git a/module/event/subsystems/bdev/bdev.c b/module/event/subsystems/bdev/bdev.c index 9b4917c7e..055e182c3 100644 --- a/module/event/subsystems/bdev/bdev.c +++ b/module/event/subsystems/bdev/bdev.c @@ -37,7 +37,7 @@ #include "spdk/env.h" #include "spdk/thread.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "spdk/env.h" static void diff --git a/module/event/subsystems/iscsi/iscsi.c b/module/event/subsystems/iscsi/iscsi.c index a131a6d30..19944cf05 100644 --- a/module/event/subsystems/iscsi/iscsi.c +++ b/module/event/subsystems/iscsi/iscsi.c @@ -35,7 +35,7 @@ #include "iscsi/iscsi.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" static void iscsi_subsystem_init_complete(void *cb_arg, int rc) diff --git a/module/event/subsystems/nbd/nbd.c b/module/event/subsystems/nbd/nbd.c index 50340c5c7..1af23b06c 100644 --- a/module/event/subsystems/nbd/nbd.c +++ b/module/event/subsystems/nbd/nbd.c @@ -35,7 +35,7 @@ #include "spdk/nbd.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" static void nbd_subsystem_init(void) diff --git a/module/event/subsystems/net/net.c b/module/event/subsystems/net/net.c index 60aca98dc..2086acf2b 100644 --- a/module/event/subsystems/net/net.c +++ b/module/event/subsystems/net/net.c @@ -35,7 +35,7 @@ #include "spdk/net.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" static void interface_subsystem_init(void) diff --git a/module/event/subsystems/nvmf/event_nvmf.h b/module/event/subsystems/nvmf/event_nvmf.h index b22927ffc..59a884e3f 100644 --- a/module/event/subsystems/nvmf/event_nvmf.h +++ b/module/event/subsystems/nvmf/event_nvmf.h @@ -39,7 +39,7 @@ #include "spdk/nvmf.h" #include "spdk/queue.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "spdk/log.h" #define ACCEPT_TIMEOUT_US 10000 /* 10ms */ diff --git a/module/event/subsystems/scsi/scsi.c b/module/event/subsystems/scsi/scsi.c index f068b0da6..daf818acf 100644 --- a/module/event/subsystems/scsi/scsi.c +++ b/module/event/subsystems/scsi/scsi.c @@ -35,7 +35,7 @@ #include "spdk/scsi.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" static void scsi_subsystem_init(void) diff --git a/module/event/subsystems/sock/sock.c b/module/event/subsystems/sock/sock.c index fdcb2160a..5777555c8 100644 --- a/module/event/subsystems/sock/sock.c +++ b/module/event/subsystems/sock/sock.c @@ -32,7 +32,7 @@ #include "spdk/stdinc.h" #include "spdk/sock.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" static void sock_subsystem_init(void) diff --git a/module/event/subsystems/vhost/vhost.c b/module/event/subsystems/vhost/vhost.c index b348cca5d..1fa9b9f13 100644 --- a/module/event/subsystems/vhost/vhost.c +++ b/module/event/subsystems/vhost/vhost.c @@ -35,7 +35,7 @@ #include "spdk/vhost.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" static void vhost_subsystem_init_done(int rc) diff --git a/module/event/subsystems/vmd/vmd.c b/module/event/subsystems/vmd/vmd.c index 2d496994c..07717453f 100644 --- a/module/event/subsystems/vmd/vmd.c +++ b/module/event/subsystems/vmd/vmd.c @@ -32,12 +32,15 @@ */ #include "spdk/stdinc.h" + +#include "spdk/json.h" #include "spdk/thread.h" #include "spdk/likely.h" +#include "spdk/log.h" #include "spdk/vmd.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "event_vmd.h" static struct spdk_poller *g_hotplug_poller; diff --git a/test/app/bdev_svc/Makefile b/test/app/bdev_svc/Makefile index 9e560de0f..a13faf085 100644 --- a/test/app/bdev_svc/Makefile +++ b/test/app/bdev_svc/Makefile @@ -39,10 +39,10 @@ APP = bdev_svc C_SRCS := bdev_svc.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev ifeq ($(OS),Linux) -SPDK_LIB_LIST += event_nbd +SPDK_LIB_LIST += event event_nbd endif include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/test/bdev/bdevio/Makefile b/test/bdev/bdevio/Makefile index a42ded076..166e48096 100644 --- a/test/bdev/bdevio/Makefile +++ b/test/bdev/bdevio/Makefile @@ -39,7 +39,7 @@ APP = bdevio C_SRCS := bdevio.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev LIBS += -lcunit diff --git a/test/bdev/bdevperf/Makefile b/test/bdev/bdevperf/Makefile index ef100188d..fac2d2104 100644 --- a/test/bdev/bdevperf/Makefile +++ b/test/bdev/bdevperf/Makefile @@ -39,7 +39,7 @@ APP = bdevperf C_SRCS := bdevperf.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev conf +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev conf ifeq ($(OS),Linux) SPDK_LIB_LIST += event_nbd diff --git a/test/blobfs/mkfs/Makefile b/test/blobfs/mkfs/Makefile index 775e49d98..6121cc524 100644 --- a/test/blobfs/mkfs/Makefile +++ b/test/blobfs/mkfs/Makefile @@ -39,6 +39,6 @@ APP = mkfs C_SRCS := mkfs.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/test/event/app_repeat/Makefile b/test/event/app_repeat/Makefile index f73b4403c..a0ff1e8dc 100644 --- a/test/event/app_repeat/Makefile +++ b/test/event/app_repeat/Makefile @@ -47,6 +47,6 @@ BLOCKDEV_LIST = bdev_malloc bdev_null BLOCKDEV_LIST += bdev_aio SYS_LIBS += -laio -SPDK_LIB_LIST += $(BLOCKDEV_LIST) +SPDK_LIB_LIST += $(BLOCKDEV_LIST) event include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/test/event/event_perf/event_perf.c b/test/event/event_perf/event_perf.c index 631ade161..77508fd28 100644 --- a/test/event/event_perf/event_perf.c +++ b/test/event/event_perf/event_perf.c @@ -35,7 +35,7 @@ #include "spdk/env.h" #include "spdk/event.h" -#include "spdk_internal/event.h" +#include "spdk_internal/init.h" #include "spdk/log.h" #include "spdk/string.h" diff --git a/test/event/scheduler/Makefile b/test/event/scheduler/Makefile index 13aa0ab94..cd58c27e8 100644 --- a/test/event/scheduler/Makefile +++ b/test/event/scheduler/Makefile @@ -38,6 +38,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk APP = scheduler C_SRCS := scheduler.c -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev conf +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev conf include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/test/external_code/hello_world/Makefile b/test/external_code/hello_world/Makefile index 4e5de3ebd..96eba7583 100644 --- a/test/external_code/hello_world/Makefile +++ b/test/external_code/hello_world/Makefile @@ -34,8 +34,8 @@ PKG_CONFIG_PATH = $(SPDK_LIB_DIR)/pkgconfig DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_env_dpdk) -SPDK_BDEV_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event_bdev) -SPDK_DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event_bdev spdk_env_dpdk) +SPDK_EVENT_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event spdk_event_bdev) +SPDK_DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event spdk_event_bdev spdk_env_dpdk) SYS_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs --static spdk_syslibs) # Shows how to compile both an external bdev and an external application against the SPDK combined shared object and dpdk shared objects. @@ -46,7 +46,7 @@ bdev_shared_combo: # Shows how to compile both an external bdev and an external application against the SPDK individual shared objects and dpdk shared objects. bdev_shared_iso: $(CC) $(COMMON_CFLAGS) -L../passthru -Wl,--no-as-needed -o hello_bdev ./hello_bdev.c \ - -lpassthru_external $(SPDK_BDEV_LIB) \ + -lpassthru_external $(SPDK_EVENT_LIB) \ $(DPDK_LIB) # Shows how to compile an external application against the SPDK combined shared object and dpdk shared objects. @@ -56,7 +56,7 @@ alone_shared_combo: # Shows how to compile an external application against the SPDK individual shared objects and dpdk shared objects. alone_shared_iso: $(CC) $(COMMON_CFLAGS) -Wl,-rpath=$(SPDK_LIB_DIR),--no-as-needed -o hello_bdev ./hello_bdev.c \ - $(SPDK_BDEV_LIB) $(DPDK_LIB) + $(SPDK_EVENT_LIB) $(DPDK_LIB) # Shows how to compile an external application against the SPDK archives. alone_static: diff --git a/test/unit/lib/Makefile b/test/unit/lib/Makefile index c7fbc5345..a7ed1eea5 100644 --- a/test/unit/lib/Makefile +++ b/test/unit/lib/Makefile @@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk DIRS-y = accel bdev blob blobfs event ioat iscsi json jsonrpc log lvol -DIRS-y += notify nvme nvmf scsi sock thread util env_dpdk +DIRS-y += notify nvme nvmf scsi sock thread util env_dpdk init DIRS-$(CONFIG_IDXD) += idxd DIRS-$(CONFIG_REDUCE) += reduce ifeq ($(OS),Linux) diff --git a/test/unit/lib/event/Makefile b/test/unit/lib/event/Makefile index ea411460c..d87b0b1e7 100644 --- a/test/unit/lib/event/Makefile +++ b/test/unit/lib/event/Makefile @@ -34,7 +34,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk -DIRS-y = subsystem.c app.c reactor.c +DIRS-y = app.c reactor.c .PHONY: all clean $(DIRS-y) diff --git a/test/unit/lib/init/Makefile b/test/unit/lib/init/Makefile new file mode 100644 index 000000000..862db3c0d --- /dev/null +++ b/test/unit/lib/init/Makefile @@ -0,0 +1,44 @@ +# +# BSD LICENSE +# +# Copyright (c) Intel Corporation. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..) +include $(SPDK_ROOT_DIR)/mk/spdk.common.mk + +DIRS-y = subsystem.c + +.PHONY: all clean $(DIRS-y) + +all: $(DIRS-y) +clean: $(DIRS-y) + +include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk diff --git a/test/unit/lib/event/subsystem.c/.gitignore b/test/unit/lib/init/subsystem.c/.gitignore similarity index 100% rename from test/unit/lib/event/subsystem.c/.gitignore rename to test/unit/lib/init/subsystem.c/.gitignore diff --git a/test/unit/lib/event/subsystem.c/Makefile b/test/unit/lib/init/subsystem.c/Makefile similarity index 100% rename from test/unit/lib/event/subsystem.c/Makefile rename to test/unit/lib/init/subsystem.c/Makefile diff --git a/test/unit/lib/event/subsystem.c/subsystem_ut.c b/test/unit/lib/init/subsystem.c/subsystem_ut.c similarity index 99% rename from test/unit/lib/event/subsystem.c/subsystem_ut.c rename to test/unit/lib/init/subsystem.c/subsystem_ut.c index 608f2e4b1..e56664aab 100644 --- a/test/unit/lib/event/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/init/subsystem.c/subsystem_ut.c @@ -36,7 +36,7 @@ #include "spdk_cunit.h" #include "unit/lib/json_mock.c" -#include "event/subsystem.c" +#include "init/subsystem.c" #include "common/lib/test_env.c" static struct spdk_subsystem g_ut_subsystems[8]; diff --git a/test/unit/unittest.sh b/test/unit/unittest.sh index e9f688c0b..493076756 100755 --- a/test/unit/unittest.sh +++ b/test/unit/unittest.sh @@ -40,7 +40,6 @@ function unittest_blob() { } function unittest_event() { - $valgrind $testdir/lib/event/subsystem.c/subsystem_ut $valgrind $testdir/lib/event/app.c/app_ut $valgrind $testdir/lib/event/reactor.c/reactor_ut } @@ -128,6 +127,10 @@ function unittest_util() { $valgrind $testdir/lib/util/pipe.c/pipe_ut } +function unittest_init() { + $valgrind $testdir/lib/init/subsystem.c/subsystem_ut +} + # if ASAN is enabled, use it. If not use valgrind if installed but allow # the env variable to override the default shown below. if [ -z ${valgrind+x} ]; then @@ -235,6 +238,8 @@ if grep -q '#define SPDK_CONFIG_VHOST 1' $rootdir/include/spdk/config.h; then run_test "unittest_vhost" $valgrind $testdir/lib/vhost/vhost.c/vhost_ut fi +run_test "unittest_init" unittest_init + if [ "$cov_avail" = "yes" ] && ! [[ "$CC_TYPE" == *"clang"* ]]; then $LCOV -q -d . -c -t "$(hostname)" -o $UT_COVERAGE/ut_cov_test.info $LCOV -q -a $UT_COVERAGE/ut_cov_base.info -a $UT_COVERAGE/ut_cov_test.info -o $UT_COVERAGE/ut_cov_total.info