From 674de775518e75a456409638d7b04893ebdd4389 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 13 Jun 2017 10:18:50 -0700 Subject: [PATCH] rpc: Add a separate subsystem library This separates the RPC library from the event framework. Change-Id: I26a9cb318b56d44ec9337f8a4db98967eb87ad95 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/365283 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- app/iscsi_tgt/Makefile | 2 +- app/nvmf_tgt/Makefile | 2 +- app/vhost/Makefile | 2 +- include/spdk/rpc.h | 4 +++ lib/event/subsystems/Makefile | 2 +- lib/event/subsystems/rpc/Makefile | 41 +++++++++++++++++++++++++++++++ lib/event/subsystems/rpc/rpc.c | 40 ++++++++++++++++++++++++++++++ lib/rocksdb/spdk.rocksdb.mk | 2 +- lib/rpc/rpc.c | 8 +++--- test/lib/bdev/bdevio/Makefile | 2 +- test/lib/bdev/bdevperf/Makefile | 2 +- test/lib/blobfs/mkfs/Makefile | 2 +- 12 files changed, 96 insertions(+), 13 deletions(-) create mode 100644 lib/event/subsystems/rpc/Makefile create mode 100644 lib/event/subsystems/rpc/rpc.c diff --git a/app/iscsi_tgt/Makefile b/app/iscsi_tgt/Makefile index 5d2b47676..5ea8f62fb 100644 --- a/app/iscsi_tgt/Makefile +++ b/app/iscsi_tgt/Makefile @@ -46,7 +46,7 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/lib C_SRCS := iscsi_tgt.c -SPDK_LIB_LIST = event_bdev event_copy event_net +SPDK_LIB_LIST = event_bdev event_copy event_net event_rpc SPDK_LIB_LIST += jsonrpc json rpc bdev_rpc bdev iscsi scsi net copy trace conf SPDK_LIB_LIST += util log log_rpc event app_rpc diff --git a/app/nvmf_tgt/Makefile b/app/nvmf_tgt/Makefile index 4dc715d07..0fb803fad 100644 --- a/app/nvmf_tgt/Makefile +++ b/app/nvmf_tgt/Makefile @@ -42,7 +42,7 @@ CFLAGS += $(ENV_CFLAGS) C_SRCS := conf.c nvmf_main.c nvmf_tgt.c nvmf_rpc.c -SPDK_LIB_LIST = event_bdev event_copy +SPDK_LIB_LIST = event_bdev event_copy event_rpc SPDK_LIB_LIST += nvmf event log trace conf util bdev copy rpc jsonrpc json SPDK_LIB_LIST += app_rpc log_rpc bdev_rpc diff --git a/app/vhost/Makefile b/app/vhost/Makefile index e0c59c224..293d64512 100644 --- a/app/vhost/Makefile +++ b/app/vhost/Makefile @@ -42,7 +42,7 @@ CFLAGS += $(ENV_CFLAGS) C_SRCS := vhost.c -SPDK_LIB_LIST = event_bdev event_copy event_net +SPDK_LIB_LIST = event_bdev event_copy event_net event_rpc SPDK_LIB_LIST += jsonrpc json rpc bdev_rpc bdev scsi net copy trace conf SPDK_LIB_LIST += util log log_rpc event app_rpc SPDK_LIB_LIST += vhost rte_vhost diff --git a/include/spdk/rpc.h b/include/spdk/rpc.h index 4b3d5c539..4f82f5f77 100644 --- a/include/spdk/rpc.h +++ b/include/spdk/rpc.h @@ -38,6 +38,10 @@ #include "spdk/jsonrpc.h" +void spdk_rpc_initialize(void); +int spdk_rpc_finish(void); +void spdk_rpc_config_text(FILE *fp); + typedef void (*spdk_rpc_method_handler)(struct spdk_jsonrpc_server_conn *conn, const struct spdk_json_val *params, const struct spdk_json_val *id); diff --git a/lib/event/subsystems/Makefile b/lib/event/subsystems/Makefile index 4ebdcb63e..217fae668 100644 --- a/lib/event/subsystems/Makefile +++ b/lib/event/subsystems/Makefile @@ -34,7 +34,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk -DIRS-y += bdev copy net +DIRS-y += bdev copy net rpc .PHONY: all clean $(DIRS-y) diff --git a/lib/event/subsystems/rpc/Makefile b/lib/event/subsystems/rpc/Makefile new file mode 100644 index 000000000..c9d16f7f5 --- /dev/null +++ b/lib/event/subsystems/rpc/Makefile @@ -0,0 +1,41 @@ +# +# 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 + +CFLAGS += $(ENV_CFLAGS) -I. +C_SRCS = rpc.c +LIBNAME = event_rpc + +include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk diff --git a/lib/event/subsystems/rpc/rpc.c b/lib/event/subsystems/rpc/rpc.c new file mode 100644 index 000000000..e6531354b --- /dev/null +++ b/lib/event/subsystems/rpc/rpc.c @@ -0,0 +1,40 @@ +/*- + * 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. + */ + +#include "spdk/stdinc.h" + +#include "spdk/rpc.h" + +#include "spdk_internal/event.h" + +SPDK_SUBSYSTEM_REGISTER(spdk_rpc, spdk_rpc_initialize, spdk_rpc_finish, spdk_rpc_config_text) diff --git a/lib/rocksdb/spdk.rocksdb.mk b/lib/rocksdb/spdk.rocksdb.mk index 53ff79e8f..df24bfd10 100644 --- a/lib/rocksdb/spdk.rocksdb.mk +++ b/lib/rocksdb/spdk.rocksdb.mk @@ -49,7 +49,7 @@ CXXFLAGS += -fno-profile-arcs -fno-test-coverage CXXFLAGS += -fno-sanitize=undefined CXXFLAGS += -fno-sanitize=address -SPDK_LIB_LIST = event_bdev event_copy +SPDK_LIB_LIST = event_bdev event_copy event_rpc SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event util conf trace \ log jsonrpc json rpc diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index c8b692b44..b9bb38c84 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -225,7 +225,7 @@ spdk_rpc_setup(void *arg) RPC_SELECT_INTERVAL); } -static void +void spdk_rpc_initialize(void) { /* @@ -239,7 +239,7 @@ spdk_rpc_initialize(void) spdk_subsystem_init_next(0); } -static int +int spdk_rpc_finish(void) { if (g_rpc_listen_addr_unix.sun_path[0]) { @@ -256,7 +256,7 @@ spdk_rpc_finish(void) return 0; } -static void +void spdk_rpc_config_text(FILE *fp) { fprintf(fp, @@ -272,5 +272,3 @@ spdk_rpc_config_text(FILE *fp) " Listen %s\n", enable_rpc() ? "Yes" : "No", rpc_get_listen_addr()); } - -SPDK_SUBSYSTEM_REGISTER(spdk_rpc, spdk_rpc_initialize, spdk_rpc_finish, spdk_rpc_config_text) diff --git a/test/lib/bdev/bdevio/Makefile b/test/lib/bdev/bdevio/Makefile index 8d68bd9c2..a5e358391 100644 --- a/test/lib/bdev/bdevio/Makefile +++ b/test/lib/bdev/bdevio/Makefile @@ -42,7 +42,7 @@ C_SRCS := bdevio.c CFLAGS += -I. $(ENV_CFLAGS) -SPDK_LIB_LIST = event_bdev event_copy +SPDK_LIB_LIST = event_bdev event_copy event_rpc SPDK_LIB_LIST += bdev copy event trace log conf util rpc jsonrpc json LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \ diff --git a/test/lib/bdev/bdevperf/Makefile b/test/lib/bdev/bdevperf/Makefile index 3c4bb3af6..2845f6c91 100644 --- a/test/lib/bdev/bdevperf/Makefile +++ b/test/lib/bdev/bdevperf/Makefile @@ -42,7 +42,7 @@ C_SRCS := bdevperf.c CFLAGS += -I. $(ENV_CFLAGS) -SPDK_LIB_LIST = event_bdev event_copy +SPDK_LIB_LIST = event_bdev event_copy event_rpc SPDK_LIB_LIST += bdev copy event trace log conf util rpc jsonrpc json LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \ diff --git a/test/lib/blobfs/mkfs/Makefile b/test/lib/blobfs/mkfs/Makefile index 1a0e6a4dd..f7e6b2772 100644 --- a/test/lib/blobfs/mkfs/Makefile +++ b/test/lib/blobfs/mkfs/Makefile @@ -41,7 +41,7 @@ APP = mkfs C_SRCS := mkfs.c CFLAGS += $(DPDK_INC) -SPDK_LIB_LIST = event_bdev event_copy +SPDK_LIB_LIST = event_bdev event_copy event_rpc SPDK_LIB_LIST += blobfs blob bdev blob_bdev copy event util conf trace \ log jsonrpc json rpc