Skip to content
Permalink
Browse files

Build ZStd as part of zfs.ko rather than as a separate module

Rename the module from zstd_zfs to just zstd

Signed-off-by: Allan Jude <allanjude@freebsd.org>
  • Loading branch information...
allanjude committed Sep 10, 2019
1 parent ff1ce93 commit 7959e9fdb9019aa5f9d3a3af5c1a370362880508
@@ -147,9 +147,9 @@ AC_CONFIG_FILES([
module/unicode/Makefile
module/zcommon/Makefile
module/zfs/Makefile
module/zstd/Makefile
module/lua/Makefile
module/icp/Makefile
module/zstd_zfs/Makefile
include/Makefile
include/os/Makefile
include/os/linux/Makefile
@@ -175,6 +175,8 @@ extern size_t lz4_compress_zfs(void *src, void *dst, size_t s_len, size_t d_len,
extern int lz4_decompress_zfs(void *src, void *dst, size_t s_len, size_t d_len,
int level);

extern void zstd_init(void);
extern void zstd_fini(void);
extern size_t zstd_compress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern int zstd_decompress(void *src, void *dst, size_t s_len, size_t d_len,
@@ -8,7 +8,7 @@ VPATH = \
$(top_srcdir)/contrib/zstd/zstd-1.4.3/lib/common \
$(top_srcdir)/contrib/zstd/zstd-1.4.3/lib/compress \
$(top_srcdir)/contrib/zstd/zstd-1.4.3/lib/decompress \
$(top_srcdir)/module/zstd_zfs \
$(top_srcdir)/module/zstd \
$(top_srcdir)/lib/libzpool

# Suppress unused but set variable warnings often due to ASSERTs
@@ -5,9 +5,9 @@ obj-m += nvpair/
obj-m += spl/
obj-m += os/linux/spl/
obj-m += unicode/
obj-m += zstd_zfs
obj-m += zcommon/
obj-m += zfs/
obj-m += zstd/
obj-m += os/linux/zfs/

INSTALL_MOD_DIR ?= extra
@@ -23,7 +23,7 @@ ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/contrib/zstd/zstd-1.4.3/lib
ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/contrib/zstd/zstd-1.4.3/lib/common
ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/contrib/zstd/zstd-1.4.3/lib/compress
ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/contrib/zstd/zstd-1.4.3/lib/decompress
ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/module/zstd_zfs/include
ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/module/zstd/include

ZFS_MODULE_CPPFLAGS += -D_KERNEL
ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@
@@ -33,7 +33,7 @@ ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@

export ZFS_MODULE_CFLAGS ZFS_MODULE_CPPFLAGS

SUBDIR_TARGETS = icp lua zstd_zfs
SUBDIR_TARGETS = icp lua

all: modules
distclean maintainer-clean: clean
@@ -144,3 +144,4 @@ $(MODULE)-$(CONFIG_ARM64) += vdev_raidz_math_aarch64_neon.o
$(MODULE)-$(CONFIG_ARM64) += vdev_raidz_math_aarch64_neonx2.o

-include @abs_top_builddir@/module/os/linux/zfs/Makefile
-include @abs_top_builddir@/module/zstd/Makefile
@@ -218,6 +218,7 @@ zio_init(void)
zio_inject_init();

lz4_init();
zstd_init();
}

void
@@ -262,6 +263,7 @@ zio_fini(void)
zio_inject_fini();

lz4_fini();
zstd_fini();
}

/*
@@ -0,0 +1,24 @@
ccflags-y += -I@abs_top_srcdir@/module/zstd/include
ccflags-y += -Wframe-larger-than=20480 -Wno-uninitialized

$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/common/zstd_common.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/common/fse_decompress.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/common/entropy_common.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/common/error_private.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/common/xxhash.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_compress.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_compress_literals.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_compress_sequences.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/fse_compress.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/hist.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/huf_compress.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_double_fast.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_fast.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_lazy.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_ldm.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/compress/zstd_opt.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/decompress/zstd_ddict.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/decompress/zstd_decompress.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/decompress/zstd_decompress_block.o
$(MODULE)-objs += ../../contrib/zstd/zstd-1.4.3/lib/decompress/huf_decompress.o
$(MODULE)-objs += ../zstd/zstd.o
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -40,10 +40,6 @@
#define qsort(base, num, size, cmp) sort(base, num, size, cmp, NULL)
#endif

#if !defined(_KERNEL) || !defined(__linux__)
#define __init
#define __exit
#endif
#define __unused __attribute__((unused))

static size_t real_zstd_compress(const char *source, char *dest, int isize,
@@ -475,7 +471,7 @@ zstd_free(void *opaque __unused, void *ptr)
}
}

extern int __init
void
zstd_init(void)
{
int i;
@@ -523,15 +519,12 @@ zstd_init(void)
zstd_dctx_emerg.ptr = kmem_alloc(
zstd_cache_size[ZSTD_KMEM_DCTX].kmem_size, KM_SLEEP);
if (zstd_dctx_emerg.ptr == NULL) {
return (1);
panic("Failed to allocate memory in zstd_init()");
}
mutex_init(&zstd_dctx_emerg.mtx, NULL, MUTEX_DEFAULT, NULL);


return (0);
}

extern void __exit
void
zstd_fini(void)
{
int i, type;
@@ -548,15 +541,7 @@ zstd_fini(void)
}
}

#if defined(__linux__) && defined(_KERNEL)
module_init(zstd_init);
module_exit(zstd_fini);
EXPORT_SYMBOL(zstd_compress);
EXPORT_SYMBOL(zstd_decompress_level);
EXPORT_SYMBOL(zstd_decompress);
EXPORT_SYMBOL(zstd_get_level);

MODULE_DESCRIPTION("ZSTD Compression for ZFS");
MODULE_LICENSE("BSD 3-Clause");
MODULE_VERSION("1.4.3");
#endif

This file was deleted.

@@ -50,7 +50,6 @@ export KMOD_ZUNICODE=@abs_top_builddir@/module/unicode/zunicode.ko
export KMOD_ZCOMMON=@abs_top_builddir@/module/zcommon/zcommon.ko
export KMOD_ZLUA=@abs_top_builddir@/module/lua/zlua.ko
export KMOD_ICP=@abs_top_builddir@/module/icp/icp.ko
export KMOD_ZSTD_ZFS=@abs_top_builddir@/module/zstd_zfs/zstd_zfs.ko
export KMOD_ZFS=@abs_top_builddir@/module/zfs/zfs.ko
endef

@@ -89,7 +89,6 @@ STRIP[4]="\${STRIP[0]}"
STRIP[5]="\${STRIP[0]}"
STRIP[6]="\${STRIP[0]}"
STRIP[7]="\${STRIP[0]}"
STRIP[8]="\${STRIP[0]}"
BUILT_MODULE_NAME[0]="zavl"
BUILT_MODULE_LOCATION[0]="module/avl/"
DEST_MODULE_LOCATION[0]="/extra/avl/avl"
@@ -114,7 +113,4 @@ DEST_MODULE_LOCATION[6]="/extra/lua/zlua"
BUILT_MODULE_NAME[7]="spl"
BUILT_MODULE_LOCATION[7]="module/spl/"
DEST_MODULE_LOCATION[7]="/extra/spl/spl"
BUILT_MODULE_NAME[8]="zstd_zfs"
BUILT_MODULE_LOCATION[8]="module/zstd_zfs/"
DEST_MODULE_LOCATION[8]="/extra/zstd_zfs/zstd_zfs"
EOF
@@ -28,7 +28,6 @@ KMOD_ZUNICODE=${KMOD_ZUNICODE:-zunicode}
KMOD_ZCOMMON=${KMOD_ZCOMMON:-zcommon}
KMOD_ZLUA=${KMOD_ZLUA:-zlua}
KMOD_ICP=${KMOD_ICP:-icp}
KMOD_ZSTD_ZFS=${KMOD_ZSTD_ZFS:-zstd_zfs}
KMOD_ZFS=${KMOD_ZFS:-zfs}


@@ -82,7 +81,7 @@ check_modules() {
MISSING_MODULES=""

for KMOD in $KMOD_SPL $KMOD_ZAVL $KMOD_ZNVPAIR \
$KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ZLUA $KMOD_ICP $KMOD_ZSTD_ZFS $KMOD_ZFS; do
$KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ZLUA $KMOD_ICP $KMOD_ZFS; do
NAME=$(basename "$KMOD" .ko)

if lsmod | grep -E -q "^${NAME}"; then
@@ -141,7 +140,7 @@ load_modules() {
fi

for KMOD in $KMOD_SPL $KMOD_ZAVL $KMOD_ZNVPAIR \
$KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ZLUA $KMOD_ICP $KMOD_ZSTD_ZFS $KMOD_ZFS; do
$KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ZLUA $KMOD_ICP $KMOD_ZFS; do
load_module "$KMOD" || return 1
done

@@ -169,7 +168,7 @@ unload_module() {
}

unload_modules() {
for KMOD in $KMOD_ZFS $KMOD_ZSTD_ZFS $KMOD_ICP $KMOD_ZLUA $KMOD_ZCOMMON $KMOD_ZUNICODE \
for KMOD in $KMOD_ZFS $KMOD_ICP $KMOD_ZLUA $KMOD_ZCOMMON $KMOD_ZUNICODE \
$KMOD_ZNVPAIR $KMOD_ZAVL $KMOD_SPL; do
NAME=$(basename "$KMOD" .ko)
USE_COUNT=$(lsmod | grep -E "^${NAME} " | awk '{print $3}')

0 comments on commit 7959e9f

Please sign in to comment.
You can’t perform that action at this time.