Commit ed2b53f3 authored by Yifan Bian's avatar Yifan Bian Committed by Tomasz Zawadzki
Browse files

ublk: add configure and event/subsystem



ublk backend could support ublk driver with kernel. Specify
configuration parameter to start it up.

Signed-off-by: default avatarYifan Bian <yifan.bian@intel.com>
Co-authored-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Change-Id: I55e7d757e04315b25e9bfab5fdcbb6621be3e29e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15680


Reviewed-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 969b5632
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -113,6 +113,9 @@ CONFIG_RBD=n
CONFIG_DAOS=n
CONFIG_DAOS_DIR=

# Build UBLK support
CONFIG_UBLK=n

# Build vhost library.
CONFIG_VHOST=y

+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ endif

ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd
ifeq ($(CONFIG_UBLK),y)
SPDK_LIB_LIST += event_ublk
endif
ifeq ($(CONFIG_VHOST),y)
SPDK_LIB_LIST += event_vhost_blk event_vhost_scsi
endif
+18 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ function usage() {
	echo " --without-dpdk-compressdev No path required."
	echo " --with-rbd                Build Ceph RBD bdev module."
	echo " --without-rbd             No path required."
	echo " --with-ublk               Build ublk library."
	echo " --without-ublk            No path required."
	echo " --with-rdma[=DIR]         Build RDMA transport for NVMf target and initiator."
	echo " --without-rdma            Accepts optional RDMA provider name. Can be \"verbs\" or \"mlx5_dv\"."
	echo "                           If no provider specified, \"verbs\" provider is used by default."
@@ -436,6 +438,12 @@ for i in "$@"; do
		--with-env=*)
			CONFIG[ENV]="${i#*=}"
			;;
		--with-ublk)
			CONFIG[UBLK]=y
			;;
		--without-ublk)
			CONFIG[UBLK]=n
			;;
		--with-rbd)
			CONFIG[RBD]=y
			;;
@@ -1025,6 +1033,16 @@ if [[ "${CONFIG[RBD]}" = "y" ]]; then
	fi
fi

if [[ "${CONFIG[UBLK]}" = "y" ]]; then
	if ! echo -e '#include <linux/ublk_cmd.h>\n#include <liburing.h>\n' \
		'int main(void) { return 0; }\n' \
		| "${BUILD_CMD[@]}" -luring - 2> /dev/null; then
		echo "--with-ublk requires liburing and ublk_drv."
		echo "Please install then re-run this script."
		exit 1
	fi
fi

if [[ "${CONFIG[ISCSI_INITIATOR]}" = "y" ]]; then
	# Fedora installs libiscsi to /usr/lib64/iscsi for some reason.
	if ! echo -e '#include <iscsi/iscsi.h>\n#include <iscsi/scsi-lowlevel.h>\n' \

include/spdk/ublk.h

0 → 100644
+42 −0
Original line number Diff line number Diff line
/*   SPDX-License-Identifier: BSD-3-Clause
 *   Copyright (C) 2022 Intel Corporation.
 *   All rights reserved.
 */

#ifndef SPDK_UBLK_H_
#define SPDK_UBLK_H_

#include "spdk/json.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*spdk_ublk_fini_cb)(void *arg);

/**
 * Initialize the ublk library.
 */
void spdk_ublk_init(void);

/**
 * Stop the ublk layer and close all running ublk block devices.
 *
 * \param cb_fn Callback to be always called.
 * \param cb_arg Passed to cb_fn.
 * \return 0 on success.
 */
int spdk_ublk_fini(spdk_ublk_fini_cb cb_fn, void *cb_arg);

/**
 * Write UBLK subsystem configuration into provided JSON context.
 *
 * \param w JSON write context
 */
void spdk_ublk_write_config_json(struct spdk_json_write_ctx *w);

#ifdef __cplusplus
}
#endif

#endif /* SPDK_UBLK_H_ */
+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ DIRS-y += bdev blob blobfs conf dma accel event json jsonrpc \
          ioat ut_mock iscsi notify init trace_parser
ifeq ($(OS),Linux)
DIRS-y += nbd ftl vfio_user
ifeq ($(CONFIG_UBLK),y)
DIRS-y += ublk
endif
endif

DIRS-$(CONFIG_OCF) += env_ocf
Loading