linux: module: weld all but spl.ko into zfs.ko

Originally it was thought it would be useful to split up the kmods
by functionality.  This would allow external consumers to only load
what was needed.  However, in practice we've never had a case where
this functionality would be needed, and conversely managing multiple
kmods can be awkward.  Therefore, this change merges all but the
spl.ko kmod in to a single zfs.ko kmod.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13274
This commit is contained in:
наб
2022-03-31 17:20:50 +02:00
committed by Brian Behlendorf
parent 310ab9d261
commit ad9e767657
40 changed files with 518 additions and 749 deletions
-69
View File
@@ -1,69 +0,0 @@
ifneq ($(KBUILD_EXTMOD),)
src = @abs_srcdir@
obj = @abs_builddir@
zstd_include = $(src)/include
else
zstd_include = $(srctree)/$(src)/include
endif
MODULE := zzstd
obj-$(CONFIG_ZFS) := $(MODULE).o
asflags-y := -I$(zstd_include)
ccflags-y := -I$(zstd_include)
# Zstd uses -O3 by default, so we should follow
ccflags-y += -O3
# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
# Set it for other compilers, too.
common_flags := -fno-tree-vectorize
# SSE register return with SSE disabled if -march=znverX is passed
common_flags += -U__BMI__
# Quiet warnings about frame size due to unused code in unmodified zstd lib
common_flags += -Wframe-larger-than=20480
ccflags-y += $(common_flags)
vanilla-objs := lib/common/entropy_common.o \
lib/common/error_private.o \
lib/common/fse_decompress.o \
lib/common/pool.o \
lib/common/zstd_common.o \
lib/compress/fse_compress.o \
lib/compress/hist.o \
lib/compress/huf_compress.o \
lib/compress/zstd_compress_literals.o \
lib/compress/zstd_compress_sequences.o \
lib/compress/zstd_compress_superblock.o \
lib/compress/zstd_compress.o \
lib/compress/zstd_double_fast.o \
lib/compress/zstd_fast.o \
lib/compress/zstd_lazy.o \
lib/compress/zstd_ldm.o \
lib/compress/zstd_opt.o \
lib/decompress/huf_decompress.o \
lib/decompress/zstd_ddict.o \
lib/decompress/zstd_decompress.o \
lib/decompress/zstd_decompress_block.o
# Disable aarch64 neon SIMD instructions for kernel mode
$(addprefix $(obj)/,$(vanilla-objs)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w $(common_flags)
$(obj)/zfs_zstd.o: ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h $(common_flags)
$(MODULE)-objs += zfs_zstd.o
$(MODULE)-objs += zstd_sparc.o
$(MODULE)-objs += $(vanilla-objs)
all:
mkdir -p lib/common lib/compress lib/decompress
gensymbols:
for obj in $(vanilla-objs); do echo; echo "/* $$obj: */"; @OBJDUMP@ -t $$obj | awk '$$2 == "g" && !/ zfs_/ {print "#define\t" $$6 " zfs_" $$6}' | sort; done >> include/zstd_compat_wrapper.h
checksymbols:
@OBJDUMP@ -t $(vanilla-objs) | awk '/file format/ {print} $$2 == "g" && !/ zfs_/ {++ret; print} END {exit ret}'
+2 -11
View File
@@ -9,7 +9,7 @@ library, besides upgrading to a newer ZSTD release.
Tree structure:
* `zfs_zstd.c` is the actual `zzstd` kernel module.
* `zfs_zstd.c` are the actual `zfs` kernel module hooks.
* `lib/` contains the unmodified version of the `Zstandard` library
* `zstd-in.c` is our template file for generating the single-file library
* `include/`: This directory contains supplemental includes for platform
@@ -25,16 +25,7 @@ To update ZSTD the following steps need to be taken:
`grep include [path to zstd]/contrib/single_file_libs/zstd-in.c | awk '{ print $2 }'`
3. Remove debug.c, threading.c, and zstdmt_compress.c.
4. Update Makefiles with resulting file lists.
~~~
Note: if the zstd library for zfs is updated to a newer version,
the macro list in include/zstd_compat_wrapper.h usually needs to be updated.
this can be done with some hand crafting of the output of the following
script (on the object file generated from the "single-file library" script in zstd's
contrib/single_file_libs):
`nm zstd.o | awk '{print "#define "$3 " zfs_" $3}' > macrotable`
5. Follow symbol renaming notes in `include/zstd_compat_wrapper.h`
## Altering ZSTD and breaking changes
+1 -1
View File
@@ -38,7 +38,7 @@
* This will cause a symbol collision with the older in-kernel zstd library.
*
* On update, truncate this file at the scissor line, rebuild the module,
* and make gensymbols.
* and make gen-zstd-symbols.
*/
#define MEM_MODULE
+5 -7
View File
@@ -702,7 +702,7 @@ zstd_meminit(void)
}
/* Release object from pool and free memory */
static void __exit
static void
release_pool(struct zstd_pool *pool)
{
mutex_destroy(&pool->barrier);
@@ -712,7 +712,7 @@ release_pool(struct zstd_pool *pool)
}
/* Release memory pool objects */
static void __exit
static void
zstd_mempool_deinit(void)
{
for (int i = 0; i < ZSTD_POOL_MAX; i++) {
@@ -758,7 +758,7 @@ zstd_init(void)
return (0);
}
extern void __exit
extern void
zstd_fini(void)
{
/* Deinitialize kstat */
@@ -776,12 +776,10 @@ zstd_fini(void)
}
#if defined(_KERNEL)
#ifdef __FreeBSD__
module_init(zstd_init);
module_exit(zstd_fini);
ZFS_MODULE_DESCRIPTION("ZSTD Compression for ZFS");
ZFS_MODULE_LICENSE("Dual BSD/GPL");
ZFS_MODULE_VERSION(ZSTD_VERSION_STRING "a");
#endif
EXPORT_SYMBOL(zfs_zstd_compress);
EXPORT_SYMBOL(zfs_zstd_decompress_level);