From 970228038f254e742941030ed7ac419641dcb8a6 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 21 Sep 2018 07:37:54 -0700 Subject: [PATCH] reduce: add configure option --with-reduce required to build reduce. This depends on libpmem being installed. We still need to work out details in pkgdep.sh and vm_setup.sh. Some distributions like Ubuntu still require configuring extra package repositories to get libpmem packages. Signed-off-by: Jim Harris Change-Id: I4e056ce1da9a1fecb4458f8f5e7ff5d61c422533 Reviewed-on: https://review.gerrithub.io/430646 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- CONFIG | 3 +++ configure | 16 ++++++++++++++++ lib/Makefile | 4 +++- lib/reduce/reduce.c | 2 ++ scripts/vagrant/autorun-spdk.conf | 1 + test/common/autotest_common.sh | 9 +++++++++ test/unit/lib/Makefile | 3 ++- test/unit/unittest.sh | 4 +++- 8 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CONFIG b/CONFIG index 78d918a9bb..3104212a2b 100644 --- a/CONFIG +++ b/CONFIG @@ -96,6 +96,9 @@ CONFIG_VIRTIO=y CONFIG_PMDK=n CONFIG_PMDK_DIR= +# Build with "reduce" (SPDK block compression) +CONFIG_REDUCE=n + # Build with VPP CONFIG_VPP=n CONFIG_VPP_DIR= diff --git a/configure b/configure index 413771328c..2490bf03c6 100755 --- a/configure +++ b/configure @@ -48,6 +48,8 @@ function usage() echo " No path required." echo " pmdk Required to build persistent memory bdev." echo " example: /usr/share/pmdk" + echo " reduce Required to build \"reduce\" (SPDK block compression)." + echo " No path required." echo " vpp Required to build VPP net module." echo " example: /vpp_repo/build-root/install-vpp-native/vpp" echo " rbd [disabled]" @@ -220,6 +222,12 @@ for i in "$@"; do --without-pmdk) CONFIG[PMDK]=n ;; + --with-reduce) + CONFIG[REDUCE]=y + ;; + --without-reduce) + CONFIG[REDUCE]=n + ;; --with-vpp) CONFIG[VPP]=y ;; @@ -367,6 +375,14 @@ if [[ "${CONFIG[CRYPTO]}" = "y" ]]; then fi fi +if [[ "${CONFIG[REDUCE]}" = "y" ]]; then + if [ ! -f /usr/include/libpmem.h ]; then + echo --with-reduce requires libpmem. + echo Please install then re-run this script. + exit 1 + fi +fi + # We are now ready to generate final configuration. But first do sanity # check to see if all keys in CONFIG array have its reflection in CONFIG file. if [ $(egrep -c "^\s*CONFIG_[[:alnum:]_]+=" CONFIG) -ne ${#CONFIG[@]} ]; then diff --git a/lib/Makefile b/lib/Makefile index a4fd1db525..5582ef6abe 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -36,13 +36,15 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk DIRS-y += bdev blob blobfs conf copy event json jsonrpc \ log lvol net rpc sock thread trace util nvme nvmf scsi ioat \ - ut_mock iscsi reduce + ut_mock iscsi ifeq ($(OS),Linux) DIRS-y += nbd DIRS-$(CONFIG_VHOST) += vhost DIRS-$(CONFIG_VIRTIO) += virtio endif +DIRS-$(CONFIG_REDUCE) += reduce + # If CONFIG_ENV is pointing at a directory in lib, build it. # Out-of-tree env implementations must be built separately by the user. ENV_NAME := $(notdir $(CONFIG_ENV)) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index e35f7f6943..3e0356da9a 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -37,6 +37,8 @@ #include "spdk/string.h" #include "spdk_internal/log.h" +#include "libpmem.h" + /* Always round up the size of the PM region to the nearest cacheline. */ #define REDUCE_PM_SIZE_ALIGNMENT 64 diff --git a/scripts/vagrant/autorun-spdk.conf b/scripts/vagrant/autorun-spdk.conf index 4a815a518e..f4998d2f3c 100644 --- a/scripts/vagrant/autorun-spdk.conf +++ b/scripts/vagrant/autorun-spdk.conf @@ -20,6 +20,7 @@ SPDK_TEST_EVENT=1 SPDK_TEST_BLOBFS=0 SPDK_TEST_PMDK=0 SPDK_TEST_LVOL=0 +SPDK_TEST_REDUCE=0 SPDK_RUN_ASAN=1 SPDK_RUN_UBSAN=1 # Reduce the size of the hugepages diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index cc71354d8c..cb7220d3c3 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -56,6 +56,7 @@ fi : ${SPDK_TEST_PMDK=1}; export SPDK_TEST_PMDK : ${SPDK_TEST_LVOL=1}; export SPDK_TEST_LVOL : ${SPDK_TEST_JSON=1}; export SPDK_TEST_JSON +: ${SPDK_TEST_REDUCE=1}; export SPDK_TEST_REDUCE : ${SPDK_RUN_ASAN=1}; export SPDK_RUN_ASAN : ${SPDK_RUN_UBSAN=1}; export SPDK_RUN_UBSAN : ${SPDK_RUN_INSTALLED_DPDK=1}; export SPDK_RUN_INSTALLED_DPDK @@ -152,6 +153,14 @@ else SPDK_TEST_PMDK=0; export SPDK_TEST_PMDK fi +if [ -f /usr/include/libpmem.h ]; then + config_params+=' --with-reduce' +else + # PMDK not installed so disable any reduce tests explicitly here + # since reduce depends on libpmem + SPDK_TEST_REDUCE=0; export SPDK_TEST_REDUCE +fi + if [ -d /usr/src/fio ]; then config_params+=' --with-fio=/usr/src/fio' fi diff --git a/test/unit/lib/Makefile b/test/unit/lib/Makefile index ca990e1e26..c1a36568e1 100644 --- a/test/unit/lib/Makefile +++ b/test/unit/lib/Makefile @@ -35,7 +35,8 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk DIRS-y = bdev blob blobfs event ioat iscsi json jsonrpc log lvol -DIRS-y += nvme nvmf reduce scsi sock thread util +DIRS-y += nvme nvmf scsi sock thread util +DIRS-$(CONFIG_REDUCE) += reduce ifeq ($(OS),Linux) DIRS-$(CONFIG_VHOST) += vhost endif diff --git a/test/unit/unittest.sh b/test/unit/unittest.sh index ae4b232710..604b54da63 100755 --- a/test/unit/unittest.sh +++ b/test/unit/unittest.sh @@ -121,7 +121,9 @@ $valgrind $testdir/lib/iscsi/iscsi.c/iscsi_ut $valgrind $testdir/lib/iscsi/init_grp.c/init_grp_ut $testdir/lib/iscsi/init_grp.c/init_grp.conf $valgrind $testdir/lib/iscsi/portal_grp.c/portal_grp_ut $testdir/lib/iscsi/portal_grp.c/portal_grp.conf -$valgrind $testdir/lib/reduce/reduce.c/reduce_ut +if grep -q '#define SPDK_CONFIG_REDUCE 1' $rootdir/config.h; then + $valgrind $testdir/lib/reduce/reduce.c/reduce_ut +fi $valgrind $testdir/lib/thread/thread.c/thread_ut