event: Shift subsystem initialization code to a separate library

This is useful for applications even if they elect not to use the SPDK
event framework.

This doesn't shift everything in one go - just the subsystem
initialization logic. Configuration file loading also needs to move
in a separate patch later.

Change-Id: Id419df1045442d416650ed90e5ee78adfdd623d7
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6641
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2021-02-26 15:00:03 -07:00 committed by Tomasz Zawadzki
parent 36cb16219e
commit af935f768e
52 changed files with 309 additions and 116 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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"

View File

@ -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));

View File

@ -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;

45
lib/init/Makefile Normal file
View File

@ -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

19
lib/init/spdk_init.map Normal file
View File

@ -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: *;
};

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -35,7 +35,7 @@
#include "spdk/nbd.h"
#include "spdk_internal/event.h"
#include "spdk_internal/init.h"
static void
nbd_subsystem_init(void)

View File

@ -35,7 +35,7 @@
#include "spdk/net.h"
#include "spdk_internal/event.h"
#include "spdk_internal/init.h"
static void
interface_subsystem_init(void)

View File

@ -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 */

View File

@ -35,7 +35,7 @@
#include "spdk/scsi.h"
#include "spdk_internal/event.h"
#include "spdk_internal/init.h"
static void
scsi_subsystem_init(void)

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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];

View File

@ -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