nbd: add nbd as one event subsystem
Add g_spdk_nbd to record multi-nbd-disk in the future. nbd subsystem will be used to init and finish g_spdk_nbd and its linked spdk_nbd_disk. Change-Id: Ia67caa57b9920d0080f8b2fa1c8e87615803e5fe Signed-off-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-on: https://review.gerrithub.io/390097 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
3b9c5e9c6a
commit
f90beaeff0
@ -37,6 +37,10 @@
|
|||||||
struct spdk_bdev;
|
struct spdk_bdev;
|
||||||
struct spdk_nbd_disk;
|
struct spdk_nbd_disk;
|
||||||
|
|
||||||
|
int spdk_nbd_init(void);
|
||||||
|
|
||||||
|
void spdk_nbd_fini(void);
|
||||||
|
|
||||||
struct spdk_nbd_disk *spdk_nbd_start(const char *bdev_name, const char *nbd_path);
|
struct spdk_nbd_disk *spdk_nbd_start(const char *bdev_name, const char *nbd_path);
|
||||||
|
|
||||||
void spdk_nbd_stop(struct spdk_nbd_disk *nbd);
|
void spdk_nbd_stop(struct spdk_nbd_disk *nbd);
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||||
|
|
||||||
DIRS-y += bdev copy iscsi net scsi vhost
|
DIRS-y += bdev copy iscsi nbd net scsi vhost
|
||||||
|
|
||||||
.PHONY: all clean $(DIRS-y)
|
.PHONY: all clean $(DIRS-y)
|
||||||
|
|
||||||
|
41
lib/event/subsystems/nbd/Makefile
Normal file
41
lib/event/subsystems/nbd/Makefile
Normal file
@ -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 = nbd.c
|
||||||
|
LIBNAME = event_nbd
|
||||||
|
|
||||||
|
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
58
lib/event/subsystems/nbd/nbd.c
Normal file
58
lib/event/subsystems/nbd/nbd.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*-
|
||||||
|
* 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/nbd.h"
|
||||||
|
|
||||||
|
#include "spdk_internal/event.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_nbd_subsystem_init(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = spdk_nbd_init();
|
||||||
|
|
||||||
|
spdk_subsystem_init_next(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_nbd_subsystem_fini(void)
|
||||||
|
{
|
||||||
|
spdk_nbd_fini();
|
||||||
|
spdk_subsystem_fini_next();
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDK_SUBSYSTEM_REGISTER(nbd, spdk_nbd_subsystem_init, spdk_nbd_subsystem_fini, NULL)
|
||||||
|
SPDK_SUBSYSTEM_DEPEND(nbd, bdev)
|
@ -79,6 +79,25 @@ struct spdk_nbd_disk {
|
|||||||
uint32_t buf_align;
|
uint32_t buf_align;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct spdk_nbd_disk_globals {
|
||||||
|
TAILQ_HEAD(, spdk_nbd_disk) disk_head;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct spdk_nbd_disk_globals g_spdk_nbd;
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_nbd_init(void)
|
||||||
|
{
|
||||||
|
TAILQ_INIT(&g_spdk_nbd.disk_head);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_nbd_fini(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_read(enum spdk_bdev_io_type io_type)
|
is_read(enum spdk_bdev_io_type io_type)
|
||||||
{
|
{
|
||||||
|
@ -42,8 +42,8 @@ C_SRCS := nbd.c
|
|||||||
|
|
||||||
CFLAGS += -I. $(ENV_CFLAGS)
|
CFLAGS += -I. $(ENV_CFLAGS)
|
||||||
|
|
||||||
SPDK_LIB_LIST = event_bdev event_copy nbd
|
SPDK_LIB_LIST = event_bdev event_copy event_nbd
|
||||||
SPDK_LIB_LIST += bdev bdev_rpc copy event trace log log_rpc conf util rpc jsonrpc json
|
SPDK_LIB_LIST += bdev bdev_rpc copy event trace log log_rpc conf util rpc jsonrpc json nbd
|
||||||
|
|
||||||
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
|
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
|
||||||
$(COPY_MODULES_LINKER_ARGS)
|
$(COPY_MODULES_LINKER_ARGS)
|
||||||
|
Loading…
Reference in New Issue
Block a user