From 5715be6d8bc7abaa3dd778f67c08d46941e79bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 31 Mar 2022 17:20:50 +0200 Subject: [PATCH 1/6] linux: module: weld all but spl.ko into zfs.ko MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- Makefile.am | 2 +- configure.ac | 11 - etc/init.d/zfs-zed.in | 3 +- include/os/freebsd/spl/sys/ccompile.h | 3 - include/os/freebsd/spl/sys/mod_os.h | 5 - include/os/linux/kernel/linux/mod_compat.h | 7 - include/sys/mod.h | 5 - module/Kbuild.in | 421 +++++++++++++++++- module/Makefile.in | 28 +- module/avl/Makefile.in | 10 - module/avl/avl.c | 22 - module/icp/Makefile.in | 90 ---- module/icp/illumos-crypto.c | 7 +- module/lua/Makefile.in | 39 -- module/lua/lapi.c | 23 - module/nvpair/Makefile.in | 13 - module/nvpair/nvpair.c | 21 - module/os/linux/spl/Makefile.in | 17 - module/os/linux/spl/spl-generic.c | 8 +- module/os/linux/zfs/Makefile.in | 38 -- module/os/linux/zfs/zfs_ioctl_os.c | 62 ++- module/spl/Makefile.in | 13 - module/unicode/Makefile.in | 11 - module/unicode/u8_textprep.c | 21 - module/zcommon/Makefile.in | 28 -- module/zcommon/zfs_prop.c | 14 +- module/zfs/Makefile.in | 158 ------- module/zstd/Makefile.in | 69 --- module/zstd/README.md | 13 +- module/zstd/include/zstd_compat_wrapper.h | 2 +- module/zstd/zfs_zstd.c | 12 +- rpm/generic/zfs-kmod.spec.in | 2 +- rpm/redhat/zfs-kmod.spec.in | 2 +- scripts/Makefile.am | 11 +- scripts/dkms.mkconf | 40 +- scripts/zfs.sh | 17 +- scripts/zfs2zol-patch.sed | 2 +- tests/zfs-tests/include/libtest.shlib | 4 +- .../zfs_rename/zfs_rename_014_neg.ksh | 6 +- .../tests/functional/simd/simd_supported.ksh | 4 +- 40 files changed, 515 insertions(+), 749 deletions(-) delete mode 100644 module/avl/Makefile.in delete mode 100644 module/icp/Makefile.in delete mode 100644 module/lua/Makefile.in delete mode 100644 module/nvpair/Makefile.in delete mode 100644 module/os/linux/spl/Makefile.in delete mode 100644 module/os/linux/zfs/Makefile.in delete mode 100644 module/spl/Makefile.in delete mode 100644 module/unicode/Makefile.in delete mode 100644 module/zcommon/Makefile.in delete mode 100644 module/zfs/Makefile.in delete mode 100644 module/zstd/Makefile.in diff --git a/Makefile.am b/Makefile.am index 098357902916..acfd83beccc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -167,7 +167,7 @@ vcscheck: PHONY += zstdcheck zstdcheck: - @$(MAKE) -C module/zstd checksymbols + @$(MAKE) -C module check-zstd-symbols PHONY += lint lint: cppcheck paxcheck diff --git a/configure.ac b/configure.ac index 380b97d62460..5240a4959105 100644 --- a/configure.ac +++ b/configure.ac @@ -171,17 +171,6 @@ AC_CONFIG_FILES([ man/Makefile module/Kbuild module/Makefile - module/avl/Makefile - module/icp/Makefile - module/lua/Makefile - module/nvpair/Makefile - module/os/linux/spl/Makefile - module/os/linux/zfs/Makefile - module/spl/Makefile - module/unicode/Makefile - module/zcommon/Makefile - module/zfs/Makefile - module/zstd/Makefile rpm/Makefile rpm/generic/Makefile rpm/generic/zfs-dkms.spec diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in index 47f742259b27..e9cf8867403c 100755 --- a/etc/init.d/zfs-zed.in +++ b/etc/init.d/zfs-zed.in @@ -69,8 +69,7 @@ do_stop() then # No pools imported, it is/should be safe/possible to # unload modules. - zfs_action "Unloading modules" rmmod zfs zunicode \ - zavl zcommon znvpair zlua spl + zfs_action "Unloading modules" rmmod zfs spl return "$?" fi } diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h index 23e637983475..a46a3a18be14 100644 --- a/include/os/freebsd/spl/sys/ccompile.h +++ b/include/os/freebsd/spl/sys/ccompile.h @@ -42,9 +42,6 @@ extern "C" { #endif #define EXPORT_SYMBOL(x) -#define MODULE_AUTHOR(s) -#define MODULE_DESCRIPTION(s) -#define MODULE_LICENSE(s) #define module_param(a, b, c) #define module_param_call(a, b, c, d, e) #define module_param_named(a, b, c, d) diff --git a/include/os/freebsd/spl/sys/mod_os.h b/include/os/freebsd/spl/sys/mod_os.h index 293bd7d2b983..3a9ebbfc3bc4 100644 --- a/include/os/freebsd/spl/sys/mod_os.h +++ b/include/os/freebsd/spl/sys/mod_os.h @@ -31,11 +31,6 @@ #include -#define ZFS_MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) - #define EXPORT_SYMBOL(x) #define module_param(a, b, c) #define MODULE_PARM_DESC(a, b) diff --git a/include/os/linux/kernel/linux/mod_compat.h b/include/os/linux/kernel/linux/mod_compat.h index a90bdf7cf2d2..78603e54f54c 100644 --- a/include/os/linux/kernel/linux/mod_compat.h +++ b/include/os/linux/kernel/linux/mod_compat.h @@ -160,11 +160,4 @@ enum scope_prefix_types { #define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp -#define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) MODULE_VERSION(s) - -#define module_init_early(fn) module_init(fn) - #endif /* _MOD_COMPAT_H */ diff --git a/include/sys/mod.h b/include/sys/mod.h index a5a73ed0ee00..aba211423773 100644 --- a/include/sys/mod.h +++ b/include/sys/mod.h @@ -30,11 +30,6 @@ * Exported symbols */ #define EXPORT_SYMBOL(x) - -#define ZFS_MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) #endif #endif /* SYS_MOD_H */ diff --git a/module/Kbuild.in b/module/Kbuild.in index 1507965c5750..4307c3da05f5 100644 --- a/module/Kbuild.in +++ b/module/Kbuild.in @@ -1,20 +1,6 @@ # When integrated in to a monolithic kernel the spl module must appear # first. This ensures its module initialization function is run before # any of the other module initialization functions which depend on it. -ZFS_MODULES += spl/ -ZFS_MODULES += avl/ -ZFS_MODULES += icp/ -ZFS_MODULES += lua/ -ZFS_MODULES += nvpair/ -ZFS_MODULES += unicode/ -ZFS_MODULES += zcommon/ -ZFS_MODULES += zfs/ -ZFS_MODULES += zstd/ - -# The rest is only relevant when run by kbuild -ifneq ($(KERNELRELEASE),) - -obj-$(CONFIG_ZFS) := $(ZFS_MODULES) ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement ZFS_MODULE_CFLAGS += -Wmissing-prototypes @@ -22,10 +8,16 @@ ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @NO_FORMAT_ZERO_LENGTH@ ifneq ($(KBUILD_EXTMOD),) zfs_include = @abs_top_srcdir@/include +icp_include = @abs_srcdir@/icp/include +zstd_include = @abs_srcdir@/zstd/include ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h ZFS_MODULE_CFLAGS += -I@abs_top_builddir@/include +src = @abs_srcdir@ +obj = @abs_builddir@ else zfs_include = $(srctree)/include/zfs +icp_include = $(srctree)/$(src)/icp/include +zstd_include = $(srctree)/$(src)/zstd/include ZFS_MODULE_CFLAGS += -include $(zfs_include)/zfs_config.h endif @@ -41,7 +33,404 @@ ifneq ($(KBUILD_EXTMOD),) @CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@ endif -subdir-asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) -subdir-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) +asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) +ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) + +# Suppress unused-value warnings in sparc64 architecture headers +ccflags-$(CONFIG_SPARC64) += -Wno-unused-value + + +obj-$(CONFIG_ZFS) := spl.o zfs.o + +SPL_OBJS := \ + spl-atomic.o \ + spl-condvar.o \ + spl-cred.o \ + spl-err.o \ + spl-generic.o \ + spl-kmem-cache.o \ + spl-kmem.o \ + spl-kstat.o \ + spl-proc.o \ + spl-procfs-list.o \ + spl-taskq.o \ + spl-thread.o \ + spl-trace.o \ + spl-tsd.o \ + spl-vmem.o \ + spl-xdr.o \ + spl-zlib.o + +spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS)) + +zfs-objs += avl/avl.o + +ICP_OBJS := \ + algs/aes/aes_impl.o \ + algs/aes/aes_impl_generic.o \ + algs/aes/aes_modes.o \ + algs/edonr/edonr.o \ + algs/modes/cbc.o \ + algs/modes/ccm.o \ + algs/modes/ctr.o \ + algs/modes/ecb.o \ + algs/modes/gcm.o \ + algs/modes/gcm_generic.o \ + algs/modes/modes.o \ + algs/sha2/sha2.o \ + algs/skein/skein.o \ + algs/skein/skein_block.o \ + algs/skein/skein_iv.o \ + api/kcf_cipher.o \ + api/kcf_ctxops.o \ + api/kcf_mac.o \ + core/kcf_callprov.o \ + core/kcf_mech_tabs.o \ + core/kcf_prov_lib.o \ + core/kcf_prov_tabs.o \ + core/kcf_sched.o \ + illumos-crypto.o \ + io/aes.o \ + io/sha2_mod.o \ + io/skein_mod.o \ + spi/kcf_spi.o + +ICP_OBJS_X86_64 := \ + asm-x86_64/aes/aes_aesni.o \ + asm-x86_64/aes/aes_amd64.o \ + asm-x86_64/aes/aeskey.o \ + asm-x86_64/modes/aesni-gcm-x86_64.o \ + asm-x86_64/modes/gcm_pclmulqdq.o \ + asm-x86_64/modes/ghash-x86_64.o \ + asm-x86_64/sha2/sha256_impl.o \ + asm-x86_64/sha2/sha512_impl.o + +ICP_OBJS_X86 := \ + algs/aes/aes_impl_aesni.o \ + algs/aes/aes_impl_x86-64.o \ + algs/modes/gcm_pclmulqdq.o + +zfs-objs += $(addprefix icp/,$(ICP_OBJS)) +zfs-$(CONFIG_X86) += $(addprefix icp/,$(ICP_OBJS_X86)) +zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64)) + +$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64)) : asflags-y += -I$(icp_include) +$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64)) : ccflags-y += -I$(icp_include) + +# Suppress objtool "can't find jump dest instruction at" warnings. They +# are caused by the constants which are defined in the text section of the +# assembly file using .byte instructions (e.g. bswap_mask). The objtool +# utility tries to interpret them as opcodes and obviously fails doing so. +OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y +OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y +# Suppress objtool "unsupported stack pointer realignment" warnings. We are +# not using a DRAP register while aligning the stack to a 64 byte boundary. +# See #6950 for the reasoning. +OBJECT_FILES_NON_STANDARD_sha256_impl.o := y +OBJECT_FILES_NON_STANDARD_sha512_impl.o := y + + +LUA_OBJS := \ + lapi.o \ + lauxlib.o \ + lbaselib.o \ + lcode.o \ + lcompat.o \ + lcorolib.o \ + lctype.o \ + ldebug.o \ + ldo.o \ + lfunc.o \ + lgc.o \ + llex.o \ + lmem.o \ + lobject.o \ + lopcodes.o \ + lparser.o \ + lstate.o \ + lstring.o \ + lstrlib.o \ + ltable.o \ + ltablib.o \ + ltm.o \ + lvm.o \ + lzio.o \ + setjmp/setjmp.o + +zfs-objs += $(addprefix lua/,$(LUA_OBJS)) + + +NVPAIR_OBJS := \ + fnvpair.o \ + nvpair.o \ + nvpair_alloc_fixed.o \ + nvpair_alloc_spl.o + +zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS)) + + +UNICODE_OBJS := \ + u8_textprep.o \ + uconv.o + +zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS)) + + +ZCOMMON_OBJS := \ + cityhash.o \ + zfeature_common.o \ + zfs_comutil.o \ + zfs_deleg.o \ + zfs_fletcher.o \ + zfs_fletcher_superscalar.o \ + zfs_fletcher_superscalar4.o \ + zfs_namecheck.o \ + zfs_prop.o \ + zpool_prop.o \ + zprop_common.o + +ZCOMMON_OBJS_X86 := \ + zfs_fletcher_avx512.o \ + zfs_fletcher_intel.o \ + zfs_fletcher_sse.o + +ZCOMMON_OBJS_ARM64 := \ + zfs_fletcher_aarch64_neon.o + +zfs-objs += $(addprefix zcommon/,$(ZCOMMON_OBJS)) +zfs-$(CONFIG_X86) += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86)) +zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64)) + + +# Zstd uses -O3 by default, so we should follow +ZFS_ZSTD_FLAGS := -O3 + +# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h +# Set it for other compilers, too. +ZFS_ZSTD_FLAGS += -fno-tree-vectorize + +# SSE register return with SSE disabled if -march=znverX is passed +ZFS_ZSTD_FLAGS += -U__BMI__ + +# Quiet warnings about frame size due to unused code in unmodified zstd lib +ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480 + +ZSTD_OBJS := \ + zfs_zstd.o \ + zstd_sparc.o + +ZSTD_UPSTREAM_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.o \ + lib/compress/zstd_compress_literals.o \ + lib/compress/zstd_compress_sequences.o \ + lib/compress/zstd_compress_superblock.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 + +zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) + +# Disable aarch64 neon SIMD instructions for kernel mode +$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS) +$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include) +$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w +$(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h + + +ZFS_OBJS := \ + abd.o \ + aggsum.o \ + arc.o \ + blkptr.o \ + bplist.o \ + bpobj.o \ + bptree.o \ + bqueue.o \ + btree.o \ + dataset_kstats.o \ + dbuf.o \ + dbuf_stats.o \ + ddt.o \ + ddt_zap.o \ + dmu.o \ + dmu_diff.o \ + dmu_object.o \ + dmu_objset.o \ + dmu_recv.o \ + dmu_redact.o \ + dmu_send.o \ + dmu_traverse.o \ + dmu_tx.o \ + dmu_zfetch.o \ + dnode.o \ + dnode_sync.o \ + dsl_bookmark.o \ + dsl_crypt.o \ + dsl_dataset.o \ + dsl_deadlist.o \ + dsl_deleg.o \ + dsl_destroy.o \ + dsl_dir.o \ + dsl_pool.o \ + dsl_prop.o \ + dsl_scan.o \ + dsl_synctask.o \ + dsl_userhold.o \ + edonr_zfs.o \ + fm.o \ + gzip.o \ + hkdf.o \ + lz4.o \ + lz4_zfs.o \ + lzjb.o \ + metaslab.o \ + mmp.o \ + multilist.o \ + objlist.o \ + pathname.o \ + range_tree.o \ + refcount.o \ + rrwlock.o \ + sa.o \ + sha256.o \ + skein_zfs.o \ + spa.o \ + spa_boot.o \ + spa_checkpoint.o \ + spa_config.o \ + spa_errlog.o \ + spa_history.o \ + spa_log_spacemap.o \ + spa_misc.o \ + spa_stats.o \ + space_map.o \ + space_reftree.o \ + txg.o \ + uberblock.o \ + unique.o \ + vdev.o \ + vdev_cache.o \ + vdev_draid.o \ + vdev_draid_rand.o \ + vdev_indirect.o \ + vdev_indirect_births.o \ + vdev_indirect_mapping.o \ + vdev_initialize.o \ + vdev_label.o \ + vdev_mirror.o \ + vdev_missing.o \ + vdev_queue.o \ + vdev_raidz.o \ + vdev_raidz_math.o \ + vdev_raidz_math_scalar.o \ + vdev_rebuild.o \ + vdev_removal.o \ + vdev_root.o \ + vdev_trim.o \ + zap.o \ + zap_leaf.o \ + zap_micro.o \ + zcp.o \ + zcp_get.o \ + zcp_global.o \ + zcp_iter.o \ + zcp_set.o \ + zcp_synctask.o \ + zfeature.o \ + zfs_byteswap.o \ + zfs_fm.o \ + zfs_fuid.o \ + zfs_ioctl.o \ + zfs_log.o \ + zfs_onexit.o \ + zfs_quota.o \ + zfs_ratelimit.o \ + zfs_replay.o \ + zfs_rlock.o \ + zfs_sa.o \ + zfs_vnops.o \ + zil.o \ + zio.o \ + zio_checksum.o \ + zio_compress.o \ + zio_inject.o \ + zle.o \ + zrlock.o \ + zthr.o \ + zvol.o + +ZFS_OBJS_OS := \ + abd_os.o \ + arc_os.o \ + mmp_os.o \ + policy.o \ + qat.o \ + qat_compress.o \ + qat_crypt.o \ + spa_misc_os.o \ + trace.o \ + vdev_disk.o \ + vdev_file.o \ + zfs_acl.o \ + zfs_ctldir.o \ + zfs_debug.o \ + zfs_dir.o \ + zfs_file_os.o \ + zfs_ioctl_os.o \ + zfs_racct.o \ + zfs_sysfs.o \ + zfs_uio.o \ + zfs_vfsops.o \ + zfs_vnops_os.o \ + zfs_znode.o \ + zio_crypt.o \ + zpl_ctldir.o \ + zpl_export.o \ + zpl_file.o \ + zpl_inode.o \ + zpl_super.o \ + zpl_xattr.o \ + zvol_os.o + +ZFS_OBJS_X86 := \ + vdev_raidz_math_avx2.o \ + vdev_raidz_math_avx512bw.o \ + vdev_raidz_math_avx512f.o \ + vdev_raidz_math_sse2.o \ + vdev_raidz_math_ssse3.o + +ZFS_OBJS_ARM64 := \ + vdev_raidz_math_aarch64_neon.o \ + vdev_raidz_math_aarch64_neonx2.o + +ZFS_OBJS_PPC_PPC64 := \ + vdev_raidz_math_powerpc_altivec.o + +zfs-objs += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS)) +zfs-$(CONFIG_X86) += $(addprefix zfs/,$(ZFS_OBJS_X86)) +zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64)) +zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64)) +zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64)) + +# Suppress incorrect warnings from versions of objtool which are not +# aware of x86 EVEX prefix instructions used for AVX512. +OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y +OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y +ifeq ($(CONFIG_ALTIVEC),y) +$(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec endif diff --git a/module/Makefile.in b/module/Makefile.in index 762f9394dd20..960cb7259bd6 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -3,8 +3,6 @@ include Kbuild INSTALL_MOD_DIR ?= extra INSTALL_MOD_PATH ?= $(DESTDIR) -SUBDIR_TARGETS = icp lua zstd - all: modules distclean maintainer-clean: clean install: modules_install @@ -51,7 +49,8 @@ endif FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS) modules-Linux: - list='$(SUBDIR_TARGETS)'; for td in $$list; do $(MAKE) -C $$td; done + mkdir -p $(sort $(dir $(spl-objs) $(spl-))) + mkdir -p $(sort $(dir $(zfs-objs) $(zfs-))) $(MAKE) -C @LINUX_OBJ@ $(if @KERNEL_CC@,CC=@KERNEL_CC@) \ $(if @KERNEL_LD@,LD=@KERNEL_LD@) $(if @KERNEL_LLVM@,LLVM=@KERNEL_LLVM@) \ M="$$PWD" @KERNEL_MAKE@ CONFIG_ZFS=m modules @@ -77,6 +76,7 @@ clean-FreeBSD: clean: clean-@ac_system@ +KMODDIR := $(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ modules_install-Linux: @# Install the kernel modules $(MAKE) -C @LINUX_OBJ@ M="$$PWD" modules_install \ @@ -84,9 +84,8 @@ modules_install-Linux: INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \ KERNELRELEASE=@LINUX_VERSION@ @# Remove extraneous build products when packaging - kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ if [ -n "$(DESTDIR)" ]; then \ - find $$kmoddir -name 'modules.*' -delete; \ + find $(KMODDIR) -name 'modules.*' -delete; \ fi @# Debian ships tiny fake System.map files that are @# syntactically valid but just say @@ -109,10 +108,7 @@ modules_install: modules_install-@ac_system@ modules_uninstall-Linux: @# Uninstall the kernel modules - kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ - for objdir in $(ZFS_MODULES); do \ - $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \ - done + $(RM) $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,zfs.ko spl.ko) modules_uninstall-FreeBSD: @false @@ -134,7 +130,7 @@ cppcheck-Linux: -I @top_srcdir@/include/os/linux/spl \ -I @top_srcdir@/include/os/linux/zfs \ -I @top_srcdir@/include \ - avl icp lua nvpair spl unicode zcommon zfs zstd os/linux + avl icp lua nvpair unicode zcommon zfs zstd os/linux cppcheck-FreeBSD: @true @@ -142,9 +138,11 @@ cppcheck-FreeBSD: cppcheck: cppcheck-@ac_system@ distdir: - (cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \ - while read path; do \ - mkdir -p $$distdir/$${path%/*}; \ - cp @srcdir@/$$path $$distdir/$$path; \ - done; \ + cd @srcdir@ && find . -name '*.[chS]' -exec sh -c 'for f; do mkdir -p $$distdir/$${f%/*}; cp @srcdir@/$$f $$distdir/$$f; done' _ {} + cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd + +gen-zstd-symbols: + for obj in $(addprefix zstd/,$(ZSTD_UPSTREAM_OBJS)); do echo; echo "/* $${obj#zstd/}: */"; @OBJDUMP@ -t $$obj | awk '$$2 == "g" && !/ zfs_/ {print "#define\t" $$6 " zfs_" $$6}' | sort; done >> zstd/include/zstd_compat_wrapper.h + +check-zstd-symbols: + @OBJDUMP@ -t $(addprefix zstd/,$(ZSTD_UPSTREAM_OBJS)) | awk '/file format/ {print} $$2 == "g" && !/ zfs_/ {++ret; print} END {exit ret}' diff --git a/module/avl/Makefile.in b/module/avl/Makefile.in deleted file mode 100644 index 991d5f95b8c0..000000000000 --- a/module/avl/Makefile.in +++ /dev/null @@ -1,10 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zavl - -obj-$(CONFIG_ZFS) := $(MODULE).o - -$(MODULE)-objs += avl.o diff --git a/module/avl/avl.c b/module/avl/avl.c index 3891a2d62880..69cb8bf6815b 100644 --- a/module/avl/avl.c +++ b/module/avl/avl.c @@ -1044,28 +1044,6 @@ avl_destroy_nodes(avl_tree_t *tree, void **cookie) return (AVL_NODE2DATA(node, off)); } -#if defined(_KERNEL) - -static int __init -avl_init(void) -{ - return (0); -} - -static void __exit -avl_fini(void) -{ -} - -module_init(avl_init); -module_exit(avl_fini); -#endif - -ZFS_MODULE_DESCRIPTION("Generic AVL tree implementation"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(avl_create); EXPORT_SYMBOL(avl_find); EXPORT_SYMBOL(avl_insert); diff --git a/module/icp/Makefile.in b/module/icp/Makefile.in deleted file mode 100644 index 72c9ab12adb7..000000000000 --- a/module/icp/Makefile.in +++ /dev/null @@ -1,90 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -icp_include = $(src)/include -else -icp_include = $(srctree)/$(src)/include -endif - -MODULE := icp - -obj-$(CONFIG_ZFS) := $(MODULE).o - -asflags-y := -I$(icp_include) -ccflags-y := -I$(icp_include) - -$(MODULE)-objs += illumos-crypto.o -$(MODULE)-objs += api/kcf_cipher.o -$(MODULE)-objs += api/kcf_mac.o -$(MODULE)-objs += api/kcf_ctxops.o -$(MODULE)-objs += core/kcf_callprov.o -$(MODULE)-objs += core/kcf_prov_tabs.o -$(MODULE)-objs += core/kcf_sched.o -$(MODULE)-objs += core/kcf_mech_tabs.o -$(MODULE)-objs += core/kcf_prov_lib.o -$(MODULE)-objs += spi/kcf_spi.o -$(MODULE)-objs += io/aes.o -$(MODULE)-objs += io/sha2_mod.o -$(MODULE)-objs += io/skein_mod.o -$(MODULE)-objs += algs/modes/cbc.o -$(MODULE)-objs += algs/modes/ccm.o -$(MODULE)-objs += algs/modes/ctr.o -$(MODULE)-objs += algs/modes/ecb.o -$(MODULE)-objs += algs/modes/gcm_generic.o -$(MODULE)-objs += algs/modes/gcm.o -$(MODULE)-objs += algs/modes/modes.o -$(MODULE)-objs += algs/aes/aes_impl_generic.o -$(MODULE)-objs += algs/aes/aes_impl.o -$(MODULE)-objs += algs/aes/aes_modes.o -$(MODULE)-objs += algs/edonr/edonr.o -$(MODULE)-objs += algs/sha2/sha2.o -$(MODULE)-objs += algs/skein/skein.o -$(MODULE)-objs += algs/skein/skein_block.o -$(MODULE)-objs += algs/skein/skein_iv.o - -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/aes/aeskey.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/aes/aes_amd64.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/aes/aes_aesni.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/modes/gcm_pclmulqdq.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/modes/aesni-gcm-x86_64.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/modes/ghash-x86_64.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/sha2/sha256_impl.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/sha2/sha512_impl.o - -$(MODULE)-$(CONFIG_X86) += algs/modes/gcm_pclmulqdq.o -$(MODULE)-$(CONFIG_X86) += algs/aes/aes_impl_aesni.o -$(MODULE)-$(CONFIG_X86) += algs/aes/aes_impl_x86-64.o - -# Suppress objtool "can't find jump dest instruction at" warnings. They -# are caused by the constants which are defined in the text section of the -# assembly file using .byte instructions (e.g. bswap_mask). The objtool -# utility tries to interpret them as opcodes and obviously fails doing so. -OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y -OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y -# Suppress objtool "unsupported stack pointer realignment" warnings. We are -# not using a DRAP register while aligning the stack to a 64 byte boundary. -# See #6950 for the reasoning. -OBJECT_FILES_NON_STANDARD_sha256_impl.o := y -OBJECT_FILES_NON_STANDARD_sha512_impl.o := y - -ICP_DIRS = \ - api \ - core \ - spi \ - io \ - os \ - algs \ - algs/aes \ - algs/edonr \ - algs/modes \ - algs/sha2 \ - algs/skein \ - asm-x86_64 \ - asm-x86_64/aes \ - asm-x86_64/modes \ - asm-x86_64/sha2 \ - asm-i386 \ - asm-generic - -all: - mkdir -p $(ICP_DIRS) diff --git a/module/icp/illumos-crypto.c b/module/icp/illumos-crypto.c index f68f6bc765a2..d17b90e7200a 100644 --- a/module/icp/illumos-crypto.c +++ b/module/icp/illumos-crypto.c @@ -104,7 +104,7 @@ * ZFS Makefiles. */ -void __exit +void icp_fini(void) { skein_mod_fini(); @@ -139,10 +139,7 @@ icp_init(void) return (0); } -#if defined(_KERNEL) +#if defined(_KERNEL) && defined(__FreeBSD__) module_exit(icp_fini); module_init(icp_init); -MODULE_AUTHOR(ZFS_META_AUTHOR); -MODULE_LICENSE(ZFS_META_LICENSE); -MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); #endif diff --git a/module/lua/Makefile.in b/module/lua/Makefile.in deleted file mode 100644 index 0a74c17e64e8..000000000000 --- a/module/lua/Makefile.in +++ /dev/null @@ -1,39 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zlua - -obj-$(CONFIG_ZFS) := $(MODULE).o - -ccflags-y := -DLUA_USE_LONGLONG - -$(MODULE)-objs += lapi.o -$(MODULE)-objs += lauxlib.o -$(MODULE)-objs += lbaselib.o -$(MODULE)-objs += lcode.o -$(MODULE)-objs += lcompat.o -$(MODULE)-objs += lcorolib.o -$(MODULE)-objs += lctype.o -$(MODULE)-objs += ldebug.o -$(MODULE)-objs += ldo.o -$(MODULE)-objs += lfunc.o -$(MODULE)-objs += lgc.o -$(MODULE)-objs += llex.o -$(MODULE)-objs += lmem.o -$(MODULE)-objs += lobject.o -$(MODULE)-objs += lopcodes.o -$(MODULE)-objs += lparser.o -$(MODULE)-objs += lstate.o -$(MODULE)-objs += lstring.o -$(MODULE)-objs += lstrlib.o -$(MODULE)-objs += ltable.o -$(MODULE)-objs += ltablib.o -$(MODULE)-objs += ltm.o -$(MODULE)-objs += lvm.o -$(MODULE)-objs += lzio.o -$(MODULE)-objs += setjmp/setjmp.o - -all: - mkdir -p setjmp diff --git a/module/lua/lapi.c b/module/lua/lapi.c index 72b0037aa9a9..726e5c2ad4bb 100644 --- a/module/lua/lapi.c +++ b/module/lua/lapi.c @@ -1278,29 +1278,6 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, luaC_objbarrier(L, f1, *up2); } -#if defined(_KERNEL) - -static int __init -lua_init(void) -{ - return (0); -} - -static void __exit -lua_fini(void) -{ -} - -module_init(lua_init); -module_exit(lua_fini); - -#endif - -ZFS_MODULE_DESCRIPTION("Lua Interpreter for ZFS"); -ZFS_MODULE_AUTHOR("Lua.org"); -ZFS_MODULE_LICENSE("Dual MIT/GPL"); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(lua_absindex); EXPORT_SYMBOL(lua_atpanic); EXPORT_SYMBOL(lua_checkstack); diff --git a/module/nvpair/Makefile.in b/module/nvpair/Makefile.in deleted file mode 100644 index d8145236674b..000000000000 --- a/module/nvpair/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := znvpair - -obj-$(CONFIG_ZFS) := $(MODULE).o - -$(MODULE)-objs += nvpair.o -$(MODULE)-objs += fnvpair.o -$(MODULE)-objs += nvpair_alloc_spl.o -$(MODULE)-objs += nvpair_alloc_fixed.o diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index a5222dac7849..a442990dade0 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -3678,27 +3678,6 @@ nvs_xdr(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen) return (err); } -#if defined(_KERNEL) -static int __init -nvpair_init(void) -{ - return (0); -} - -static void __exit -nvpair_fini(void) -{ -} - -module_init(nvpair_init); -module_exit(nvpair_fini); -#endif - -ZFS_MODULE_DESCRIPTION("Generic name/value pair implementation"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(nv_alloc_init); EXPORT_SYMBOL(nv_alloc_reset); EXPORT_SYMBOL(nv_alloc_fini); diff --git a/module/os/linux/spl/Makefile.in b/module/os/linux/spl/Makefile.in deleted file mode 100644 index b2325f91b4a7..000000000000 --- a/module/os/linux/spl/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -$(MODULE)-objs += ../os/linux/spl/spl-atomic.o -$(MODULE)-objs += ../os/linux/spl/spl-condvar.o -$(MODULE)-objs += ../os/linux/spl/spl-cred.o -$(MODULE)-objs += ../os/linux/spl/spl-err.o -$(MODULE)-objs += ../os/linux/spl/spl-generic.o -$(MODULE)-objs += ../os/linux/spl/spl-kmem.o -$(MODULE)-objs += ../os/linux/spl/spl-kmem-cache.o -$(MODULE)-objs += ../os/linux/spl/spl-kstat.o -$(MODULE)-objs += ../os/linux/spl/spl-proc.o -$(MODULE)-objs += ../os/linux/spl/spl-procfs-list.o -$(MODULE)-objs += ../os/linux/spl/spl-taskq.o -$(MODULE)-objs += ../os/linux/spl/spl-thread.o -$(MODULE)-objs += ../os/linux/spl/spl-trace.o -$(MODULE)-objs += ../os/linux/spl/spl-tsd.o -$(MODULE)-objs += ../os/linux/spl/spl-vmem.o -$(MODULE)-objs += ../os/linux/spl/spl-xdr.o -$(MODULE)-objs += ../os/linux/spl/spl-zlib.o diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c index cc9a973fef62..143f34598588 100644 --- a/module/os/linux/spl/spl-generic.c +++ b/module/os/linux/spl/spl-generic.c @@ -828,7 +828,7 @@ spl_fini(void) module_init(spl_init); module_exit(spl_fini); -ZFS_MODULE_DESCRIPTION("Solaris Porting Layer"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE("GPL"); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); +MODULE_DESCRIPTION("Solaris Porting Layer"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE("GPL"); +MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); diff --git a/module/os/linux/zfs/Makefile.in b/module/os/linux/zfs/Makefile.in deleted file mode 100644 index fa990776db83..000000000000 --- a/module/os/linux/zfs/Makefile.in +++ /dev/null @@ -1,38 +0,0 @@ -# -# Linux specific sources included from module/zfs/Makefile.in -# - -# Suppress unused-value warnings in sparc64 architecture headers -ccflags-$(CONFIG_SPARC64) += -Wno-unused-value - -$(MODULE)-objs += ../os/linux/zfs/abd_os.o -$(MODULE)-objs += ../os/linux/zfs/arc_os.o -$(MODULE)-objs += ../os/linux/zfs/mmp_os.o -$(MODULE)-objs += ../os/linux/zfs/policy.o -$(MODULE)-objs += ../os/linux/zfs/trace.o -$(MODULE)-objs += ../os/linux/zfs/qat.o -$(MODULE)-objs += ../os/linux/zfs/qat_compress.o -$(MODULE)-objs += ../os/linux/zfs/qat_crypt.o -$(MODULE)-objs += ../os/linux/zfs/spa_misc_os.o -$(MODULE)-objs += ../os/linux/zfs/vdev_disk.o -$(MODULE)-objs += ../os/linux/zfs/vdev_file.o -$(MODULE)-objs += ../os/linux/zfs/zfs_acl.o -$(MODULE)-objs += ../os/linux/zfs/zfs_ctldir.o -$(MODULE)-objs += ../os/linux/zfs/zfs_debug.o -$(MODULE)-objs += ../os/linux/zfs/zfs_dir.o -$(MODULE)-objs += ../os/linux/zfs/zfs_file_os.o -$(MODULE)-objs += ../os/linux/zfs/zfs_ioctl_os.o -$(MODULE)-objs += ../os/linux/zfs/zfs_racct.o -$(MODULE)-objs += ../os/linux/zfs/zfs_sysfs.o -$(MODULE)-objs += ../os/linux/zfs/zfs_uio.o -$(MODULE)-objs += ../os/linux/zfs/zfs_vfsops.o -$(MODULE)-objs += ../os/linux/zfs/zfs_vnops_os.o -$(MODULE)-objs += ../os/linux/zfs/zfs_znode.o -$(MODULE)-objs += ../os/linux/zfs/zio_crypt.o -$(MODULE)-objs += ../os/linux/zfs/zpl_ctldir.o -$(MODULE)-objs += ../os/linux/zfs/zpl_export.o -$(MODULE)-objs += ../os/linux/zfs/zpl_file.o -$(MODULE)-objs += ../os/linux/zfs/zpl_inode.o -$(MODULE)-objs += ../os/linux/zfs/zpl_super.o -$(MODULE)-objs += ../os/linux/zfs/zpl_xattr.o -$(MODULE)-objs += ../os/linux/zfs/zvol_os.o diff --git a/module/os/linux/zfs/zfs_ioctl_os.c b/module/os/linux/zfs/zfs_ioctl_os.c index fee3fe540b90..9465ef0632ba 100644 --- a/module/os/linux/zfs/zfs_ioctl_os.c +++ b/module/os/linux/zfs/zfs_ioctl_os.c @@ -58,6 +58,8 @@ #include #include #include +#include +#include #include @@ -233,8 +235,8 @@ zfsdev_detach(void) #define ZFS_DEBUG_STR "" #endif -static int __init -openzfs_init(void) +static int +openzfs_init_os(void) { int error; @@ -259,8 +261,8 @@ openzfs_init(void) return (0); } -static void __exit -openzfs_fini(void) +static void +openzfs_fini_os(void) { zfs_sysfs_fini(); zfs_kmod_fini(); @@ -269,12 +271,56 @@ openzfs_fini(void) ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR); } + +extern int __init zcommon_init(void); +extern void zcommon_fini(void); + +static int __init +openzfs_init(void) +{ + int err; + if ((err = zcommon_init()) != 0) + goto zcommon_failed; + if ((err = icp_init()) != 0) + goto icp_failed; + if ((err = zstd_init()) != 0) + goto zstd_failed; + if ((err = openzfs_init_os()) != 0) + goto openzfs_os_failed; + return (0); + +openzfs_os_failed: + zstd_fini(); +zstd_failed: + icp_fini(); +icp_failed: + zcommon_fini(); +zcommon_failed: + return (err); +} + +static void __exit +openzfs_fini(void) +{ + openzfs_fini_os(); + zstd_fini(); + icp_fini(); + zcommon_fini(); +} + #if defined(_KERNEL) module_init(openzfs_init); module_exit(openzfs_fini); #endif -ZFS_MODULE_DESCRIPTION("ZFS"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); +MODULE_ALIAS("zavl"); +MODULE_ALIAS("icp"); +MODULE_ALIAS("zlua"); +MODULE_ALIAS("znvpair"); +MODULE_ALIAS("zunicode"); +MODULE_ALIAS("zcommon"); +MODULE_ALIAS("zzstd"); +MODULE_DESCRIPTION("ZFS"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); +MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); diff --git a/module/spl/Makefile.in b/module/spl/Makefile.in deleted file mode 100644 index cedbfe92b58a..000000000000 --- a/module/spl/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -mfdir = $(obj) -else -mfdir = $(srctree)/$(src) -endif - -MODULE := spl - -obj-$(CONFIG_ZFS) := $(MODULE).o - -include $(mfdir)/../os/linux/spl/Makefile diff --git a/module/unicode/Makefile.in b/module/unicode/Makefile.in deleted file mode 100644 index 59c07c4555b7..000000000000 --- a/module/unicode/Makefile.in +++ /dev/null @@ -1,11 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zunicode - -obj-$(CONFIG_ZFS) := $(MODULE).o - -$(MODULE)-objs += u8_textprep.o -$(MODULE)-objs += uconv.o diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index b6b07b2453af..37d648b2172d 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -2129,27 +2129,6 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen, return (ret_val); } -#if defined(_KERNEL) -static int __init -unicode_init(void) -{ - return (0); -} - -static void __exit -unicode_fini(void) -{ -} - -module_init(unicode_init); -module_exit(unicode_fini); -#endif - -ZFS_MODULE_DESCRIPTION("Unicode implementation"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(u8_validate); EXPORT_SYMBOL(u8_strcmp); EXPORT_SYMBOL(u8_textprep_str); diff --git a/module/zcommon/Makefile.in b/module/zcommon/Makefile.in deleted file mode 100644 index ebc538440445..000000000000 --- a/module/zcommon/Makefile.in +++ /dev/null @@ -1,28 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zcommon - -obj-$(CONFIG_ZFS) := $(MODULE).o - -# Suppress unused-value warnings in sparc64 architecture headers -ccflags-$(CONFIG_SPARC64) += -Wno-unused-value - -$(MODULE)-objs += cityhash.o -$(MODULE)-objs += zfeature_common.o -$(MODULE)-objs += zfs_comutil.o -$(MODULE)-objs += zfs_deleg.o -$(MODULE)-objs += zfs_fletcher.o -$(MODULE)-objs += zfs_fletcher_superscalar.o -$(MODULE)-objs += zfs_fletcher_superscalar4.o -$(MODULE)-objs += zfs_namecheck.o -$(MODULE)-objs += zfs_prop.o -$(MODULE)-objs += zpool_prop.o -$(MODULE)-objs += zprop_common.o - -$(MODULE)-$(CONFIG_X86) += zfs_fletcher_intel.o -$(MODULE)-$(CONFIG_X86) += zfs_fletcher_sse.o -$(MODULE)-$(CONFIG_X86) += zfs_fletcher_avx512.o -$(MODULE)-$(CONFIG_ARM64) += zfs_fletcher_aarch64_neon.o diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 8b3e774d99ec..500d80a33b6b 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -1006,7 +1006,10 @@ uint8_t **zfs_kfpu_fpregs; EXPORT_SYMBOL(zfs_kfpu_fpregs); #endif /* defined(HAVE_KERNEL_FPU_INTERNAL) */ -static int __init +extern int __init zcommon_init(void); +extern void zcommon_fini(void); + +int __init zcommon_init(void) { int error = kfpu_init(); @@ -1018,22 +1021,19 @@ zcommon_init(void) return (0); } -static void __exit +void zcommon_fini(void) { fletcher_4_fini(); kfpu_fini(); } +#ifdef __FreeBSD__ module_init_early(zcommon_init); module_exit(zcommon_fini); - #endif -ZFS_MODULE_DESCRIPTION("Generic ZFS support"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); +#endif /* zfs dataset property functions */ EXPORT_SYMBOL(zfs_userquota_prop_prefixes); diff --git a/module/zfs/Makefile.in b/module/zfs/Makefile.in deleted file mode 100644 index 30dc91a7eb59..000000000000 --- a/module/zfs/Makefile.in +++ /dev/null @@ -1,158 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -mfdir = $(obj) -else -mfdir = $(srctree)/$(src) -endif - -MODULE := zfs - -obj-$(CONFIG_ZFS) := $(MODULE).o - -# Suppress unused-value warnings in sparc64 architecture headers -ccflags-$(CONFIG_SPARC64) += -Wno-unused-value - -$(MODULE)-objs += abd.o -$(MODULE)-objs += aggsum.o -$(MODULE)-objs += arc.o -$(MODULE)-objs += blkptr.o -$(MODULE)-objs += bplist.o -$(MODULE)-objs += bpobj.o -$(MODULE)-objs += bptree.o -$(MODULE)-objs += btree.o -$(MODULE)-objs += bqueue.o -$(MODULE)-objs += dataset_kstats.o -$(MODULE)-objs += dbuf.o -$(MODULE)-objs += dbuf_stats.o -$(MODULE)-objs += ddt.o -$(MODULE)-objs += ddt_zap.o -$(MODULE)-objs += dmu.o -$(MODULE)-objs += dmu_diff.o -$(MODULE)-objs += dmu_object.o -$(MODULE)-objs += dmu_objset.o -$(MODULE)-objs += dmu_recv.o -$(MODULE)-objs += dmu_redact.o -$(MODULE)-objs += dmu_send.o -$(MODULE)-objs += dmu_traverse.o -$(MODULE)-objs += dmu_tx.o -$(MODULE)-objs += dmu_zfetch.o -$(MODULE)-objs += dnode.o -$(MODULE)-objs += dnode_sync.o -$(MODULE)-objs += dsl_bookmark.o -$(MODULE)-objs += dsl_crypt.o -$(MODULE)-objs += dsl_dataset.o -$(MODULE)-objs += dsl_deadlist.o -$(MODULE)-objs += dsl_deleg.o -$(MODULE)-objs += dsl_destroy.o -$(MODULE)-objs += dsl_dir.o -$(MODULE)-objs += dsl_pool.o -$(MODULE)-objs += dsl_prop.o -$(MODULE)-objs += dsl_scan.o -$(MODULE)-objs += dsl_synctask.o -$(MODULE)-objs += dsl_userhold.o -$(MODULE)-objs += edonr_zfs.o -$(MODULE)-objs += fm.o -$(MODULE)-objs += gzip.o -$(MODULE)-objs += hkdf.o -$(MODULE)-objs += lz4.o -$(MODULE)-objs += lz4_zfs.o -$(MODULE)-objs += lzjb.o -$(MODULE)-objs += metaslab.o -$(MODULE)-objs += mmp.o -$(MODULE)-objs += multilist.o -$(MODULE)-objs += objlist.o -$(MODULE)-objs += pathname.o -$(MODULE)-objs += range_tree.o -$(MODULE)-objs += refcount.o -$(MODULE)-objs += rrwlock.o -$(MODULE)-objs += sa.o -$(MODULE)-objs += sha256.o -$(MODULE)-objs += skein_zfs.o -$(MODULE)-objs += spa.o -$(MODULE)-objs += spa_boot.o -$(MODULE)-objs += spa_checkpoint.o -$(MODULE)-objs += spa_config.o -$(MODULE)-objs += spa_errlog.o -$(MODULE)-objs += spa_history.o -$(MODULE)-objs += spa_log_spacemap.o -$(MODULE)-objs += spa_misc.o -$(MODULE)-objs += spa_stats.o -$(MODULE)-objs += space_map.o -$(MODULE)-objs += space_reftree.o -$(MODULE)-objs += txg.o -$(MODULE)-objs += uberblock.o -$(MODULE)-objs += unique.o -$(MODULE)-objs += vdev.o -$(MODULE)-objs += vdev_cache.o -$(MODULE)-objs += vdev_draid.o -$(MODULE)-objs += vdev_draid_rand.o -$(MODULE)-objs += vdev_indirect.o -$(MODULE)-objs += vdev_indirect_births.o -$(MODULE)-objs += vdev_indirect_mapping.o -$(MODULE)-objs += vdev_initialize.o -$(MODULE)-objs += vdev_label.o -$(MODULE)-objs += vdev_mirror.o -$(MODULE)-objs += vdev_missing.o -$(MODULE)-objs += vdev_queue.o -$(MODULE)-objs += vdev_raidz.o -$(MODULE)-objs += vdev_raidz_math.o -$(MODULE)-objs += vdev_raidz_math_scalar.o -$(MODULE)-objs += vdev_rebuild.o -$(MODULE)-objs += vdev_removal.o -$(MODULE)-objs += vdev_root.o -$(MODULE)-objs += vdev_trim.o -$(MODULE)-objs += zap.o -$(MODULE)-objs += zap_leaf.o -$(MODULE)-objs += zap_micro.o -$(MODULE)-objs += zcp.o -$(MODULE)-objs += zcp_get.o -$(MODULE)-objs += zcp_global.o -$(MODULE)-objs += zcp_iter.o -$(MODULE)-objs += zcp_set.o -$(MODULE)-objs += zcp_synctask.o -$(MODULE)-objs += zfeature.o -$(MODULE)-objs += zfs_byteswap.o -$(MODULE)-objs += zfs_fm.o -$(MODULE)-objs += zfs_fuid.o -$(MODULE)-objs += zfs_ioctl.o -$(MODULE)-objs += zfs_log.o -$(MODULE)-objs += zfs_onexit.o -$(MODULE)-objs += zfs_quota.o -$(MODULE)-objs += zfs_ratelimit.o -$(MODULE)-objs += zfs_replay.o -$(MODULE)-objs += zfs_rlock.o -$(MODULE)-objs += zfs_sa.o -$(MODULE)-objs += zfs_vnops.o -$(MODULE)-objs += zil.o -$(MODULE)-objs += zio.o -$(MODULE)-objs += zio_checksum.o -$(MODULE)-objs += zio_compress.o -$(MODULE)-objs += zio_inject.o -$(MODULE)-objs += zle.o -$(MODULE)-objs += zrlock.o -$(MODULE)-objs += zthr.o -$(MODULE)-objs += zvol.o - -# Suppress incorrect warnings from versions of objtool which are not -# aware of x86 EVEX prefix instructions used for AVX512. -OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y -OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y - -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_sse2.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_ssse3.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_avx2.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_avx512f.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_avx512bw.o - -$(MODULE)-$(CONFIG_ARM64) += vdev_raidz_math_aarch64_neon.o -$(MODULE)-$(CONFIG_ARM64) += vdev_raidz_math_aarch64_neonx2.o - -$(MODULE)-$(CONFIG_PPC) += vdev_raidz_math_powerpc_altivec.o -$(MODULE)-$(CONFIG_PPC64) += vdev_raidz_math_powerpc_altivec.o - -ifeq ($(CONFIG_ALTIVEC),y) -$(obj)/vdev_raidz_math_powerpc_altivec.o: c_flags += -maltivec -endif - -include $(mfdir)/../os/linux/zfs/Makefile diff --git a/module/zstd/Makefile.in b/module/zstd/Makefile.in deleted file mode 100644 index 80096c3e379d..000000000000 --- a/module/zstd/Makefile.in +++ /dev/null @@ -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}' diff --git a/module/zstd/README.md b/module/zstd/README.md index 26d618b61b6e..7ad00e0bd804 100644 --- a/module/zstd/README.md +++ b/module/zstd/README.md @@ -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 diff --git a/module/zstd/include/zstd_compat_wrapper.h b/module/zstd/include/zstd_compat_wrapper.h index de428175c7df..2c4baad27d4e 100644 --- a/module/zstd/include/zstd_compat_wrapper.h +++ b/module/zstd/include/zstd_compat_wrapper.h @@ -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 diff --git a/module/zstd/zfs_zstd.c b/module/zstd/zfs_zstd.c index 5ae164663988..04e52ae3cec6 100644 --- a/module/zstd/zfs_zstd.c +++ b/module/zstd/zfs_zstd.c @@ -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); diff --git a/rpm/generic/zfs-kmod.spec.in b/rpm/generic/zfs-kmod.spec.in index 53b1e1385159..4ed719b8fe14 100644 --- a/rpm/generic/zfs-kmod.spec.in +++ b/rpm/generic/zfs-kmod.spec.in @@ -162,7 +162,7 @@ for kernel_version in %{?kernel_versions}; do cd .. done # find-debuginfo.sh only considers executables -chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/* +chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/* %{?akmod_install} diff --git a/rpm/redhat/zfs-kmod.spec.in b/rpm/redhat/zfs-kmod.spec.in index 7b74fdc51f43..2cb0623aa06f 100644 --- a/rpm/redhat/zfs-kmod.spec.in +++ b/rpm/redhat/zfs-kmod.spec.in @@ -82,7 +82,7 @@ make install \ %{__rm} -f %{buildroot}/lib/modules/%{kverrel}/modules.* # find-debuginfo.sh only considers executables -%{__chmod} u+x %{buildroot}/lib/modules/%{kverrel}/extra/*/*/* +%{__chmod} u+x %{buildroot}/lib/modules/%{kverrel}/extra/*/* %clean rm -rf $RPM_BUILD_ROOT diff --git a/scripts/Makefile.am b/scripts/Makefile.am index e2772cf1d605..fffeb6b212d5 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -54,16 +54,9 @@ export INSTALL_MOUNT_HELPER_DIR=@mounthelperdir@ export INSTALL_SYSCONF_DIR=@sysconfdir@ export INSTALL_PYTHON_DIR=@pythonsitedir@ -export KMOD_SPL=@abs_top_builddir@/module/spl/spl.ko -export KMOD_ZAVL=@abs_top_builddir@/module/avl/zavl.ko -export KMOD_ZNVPAIR=@abs_top_builddir@/module/nvpair/znvpair.ko -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_ZFS=@abs_top_builddir@/module/zfs/zfs.ko +export KMOD_SPL=@abs_top_builddir@/module/spl.ko +export KMOD_ZFS=@abs_top_builddir@/module/zfs.ko export KMOD_FREEBSD=@abs_top_builddir@/module/openzfs.ko -export KMOD_ZZSTD=@abs_top_builddir@/module/zstd/zzstd.ko endef export EXTRA_ENVIRONMENT diff --git a/scripts/dkms.mkconf b/scripts/dkms.mkconf index 4090efa087f7..0bd383420435 100755 --- a/scripts/dkms.mkconf +++ b/scripts/dkms.mkconf @@ -77,38 +77,10 @@ STRIP[0]="\$( && echo -n no )" STRIP[1]="\${STRIP[0]}" -STRIP[2]="\${STRIP[0]}" -STRIP[3]="\${STRIP[0]}" -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" -BUILT_MODULE_NAME[1]="znvpair" -BUILT_MODULE_LOCATION[1]="module/nvpair/" -DEST_MODULE_LOCATION[1]="/extra/nvpair/znvpair" -BUILT_MODULE_NAME[2]="zunicode" -BUILT_MODULE_LOCATION[2]="module/unicode/" -DEST_MODULE_LOCATION[2]="/extra/unicode/zunicode" -BUILT_MODULE_NAME[3]="zcommon" -BUILT_MODULE_LOCATION[3]="module/zcommon/" -DEST_MODULE_LOCATION[3]="/extra/zcommon/zcommon" -BUILT_MODULE_NAME[4]="zfs" -BUILT_MODULE_LOCATION[4]="module/zfs/" -DEST_MODULE_LOCATION[4]="/extra/zfs/zfs" -BUILT_MODULE_NAME[5]="icp" -BUILT_MODULE_LOCATION[5]="module/icp/" -DEST_MODULE_LOCATION[5]="/extra/icp/icp" -BUILT_MODULE_NAME[6]="zlua" -BUILT_MODULE_LOCATION[6]="module/lua/" -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]="zzstd" -BUILT_MODULE_LOCATION[8]="module/zstd/" -DEST_MODULE_LOCATION[8]="/extra/zstd/zzstd" +BUILT_MODULE_NAME[0]="zfs" +BUILT_MODULE_LOCATION[0]="module/" +DEST_MODULE_LOCATION[0]="/extra" +BUILT_MODULE_NAME[1]="spl" +BUILT_MODULE_LOCATION[1]="module/" +DEST_MODULE_LOCATION[1]="/extra" EOF diff --git a/scripts/zfs.sh b/scripts/zfs.sh index edce2cbd4c64..5689d2576a18 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -23,15 +23,8 @@ LDMOD=${LDMOD:-/sbin/modprobe} KMOD_ZLIB_DEFLATE=${KMOD_ZLIB_DEFLATE:-zlib_deflate} KMOD_ZLIB_INFLATE=${KMOD_ZLIB_INFLATE:-zlib_inflate} KMOD_SPL=${KMOD_SPL:-spl} -KMOD_ZAVL=${KMOD_ZAVL:-zavl} -KMOD_ZNVPAIR=${KMOD_ZNVPAIR:-znvpair} -KMOD_ZUNICODE=${KMOD_ZUNICODE:-zunicode} -KMOD_ZCOMMON=${KMOD_ZCOMMON:-zcommon} -KMOD_ZLUA=${KMOD_ZLUA:-zlua} -KMOD_ICP=${KMOD_ICP:-icp} KMOD_ZFS=${KMOD_ZFS:-zfs} KMOD_FREEBSD=${KMOD_FREEBSD:-openzfs} -KMOD_ZZSTD=${KMOD_ZZSTD:-zzstd} usage() { @@ -91,8 +84,7 @@ check_modules_linux() { LOADED_MODULES="" MISSING_MODULES="" - for KMOD in $KMOD_SPL $KMOD_ZAVL $KMOD_ZNVPAIR $KMOD_ZUNICODE $KMOD_ZCOMMON \ - $KMOD_ZLUA $KMOD_ZZSTD $KMOD_ICP $KMOD_ZFS; do + for KMOD in $KMOD_SPL $KMOD_ZFS; do NAME="${KMOD##*/}" NAME="${NAME%.ko}" @@ -159,9 +151,7 @@ load_modules_linux() { modprobe "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1 fi - for KMOD in $KMOD_SPL $KMOD_ZAVL $KMOD_ZNVPAIR \ - $KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ZLUA $KMOD_ZZSTD \ - $KMOD_ICP $KMOD_ZFS; do + for KMOD in $KMOD_SPL $KMOD_ZFS; do load_module_linux "$KMOD" || return 1 done @@ -200,8 +190,7 @@ unload_modules_freebsd() { } unload_modules_linux() { - for KMOD in $KMOD_ZFS $KMOD_ICP $KMOD_ZZSTD $KMOD_ZLUA $KMOD_ZCOMMON \ - $KMOD_ZUNICODE $KMOD_ZNVPAIR $KMOD_ZAVL $KMOD_SPL; do + for KMOD in $KMOD_ZFS $KMOD_SPL; do NAME="${KMOD##*/}" NAME="${NAME%.ko}" USE_COUNT=$(lsmod | awk '/^'"${NAME}"'/ {print $3}') diff --git a/scripts/zfs2zol-patch.sed b/scripts/zfs2zol-patch.sed index 99824d6dd4af..2d744cd5de52 100755 --- a/scripts/zfs2zol-patch.sed +++ b/scripts/zfs2zol-patch.sed @@ -19,7 +19,7 @@ s:usr/src/test/zfs-tests/runfiles:tests/runfiles:g s:usr/src/test/zfs-tests/tests/functional:tests/zfs-tests/tests/functional:g s:usr/src/test/zfs-tests/tests/perf:tests/zfs-tests/tests/perf:g s:usr/src/test/test-runner/cmd/run.py:tests/test-runner/cmd/test-runner.py:g -s/usr\/src\/common\/zfs\/\(.*\)\.c/module\/zcommon\/\1.c/g +s:usr/src/common/zfs/\(.*\)\.c:module/zcommon/\1.c:g # crypto framework s:usr/src/common/crypto:module/icp/algs:g diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 3917dc32bd81..b24ba6cb6615 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3264,7 +3264,6 @@ function set_tunable_impl typeset name="$1" typeset value="$2" typeset mdb_cmd="$3" - typeset module="${4:-zfs}" eval "typeset tunable=\$$name" case "$tunable" in @@ -3283,14 +3282,13 @@ function set_tunable_impl case "$UNAME" in Linux) - typeset zfs_tunables="/sys/module/$module/parameters" + typeset zfs_tunables="/sys/module/zfs/parameters" echo "$value" >"$zfs_tunables/$tunable" ;; FreeBSD) sysctl vfs.zfs.$tunable=$value ;; SunOS) - [[ "$module" -eq "zfs" ]] || return 1 echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw ;; esac diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh index 1c962608d784..57bae24277e1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh @@ -81,7 +81,7 @@ function nesting_cleanup # before resetting it, it will be left at the modified # value for the remaining tests. That's the reason # we reset it again here just in case. - log_must set_tunable_impl MAX_DATASET_NESTING 50 Z zcommon + log_must set_tunable64 MAX_DATASET_NESTING 50 Z } log_onexit nesting_cleanup @@ -93,13 +93,13 @@ log_must zfs create -p $TESTPOOL/$dsC16 log_mustnot zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB15A # extend limit -log_must set_tunable_impl MAX_DATASET_NESTING 64 Z zcommon +log_must set_tunable64 MAX_DATASET_NESTING 64 Z log_mustnot zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB16A log_must zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB15A # bring back old limit -log_must set_tunable_impl MAX_DATASET_NESTING 50 Z zcommon +log_must set_tunable64 MAX_DATASET_NESTING 50 Z log_mustnot zfs rename $TESTPOOL/$dsC01 $TESTPOOL/$dsB15A47C log_must zfs rename $TESTPOOL/$dsB15A47A $TESTPOOL/$dsB15A47B diff --git a/tests/zfs-tests/tests/functional/simd/simd_supported.ksh b/tests/zfs-tests/tests/functional/simd/simd_supported.ksh index 8b45e51bc257..1c89824e02fd 100755 --- a/tests/zfs-tests/tests/functional/simd/simd_supported.ksh +++ b/tests/zfs-tests/tests/functional/simd/simd_supported.ksh @@ -32,7 +32,7 @@ # # STRATEGY: # 1. Test if we are running on a Linux x86 system with SSE support -# 2. If so, check if the zfs_fletcher_4_impl module parameter contains +# 2. If so, check if the zfs_fletcher_4_impl module parameter contains # a sse implementation # 3. If not fail the test, otherwise pass it @@ -44,7 +44,7 @@ fi case "$(uname -m)" in i?86|x86_64) - typeset -R modparam="/sys/module/zcommon/parameters/zfs_fletcher_4_impl" + typeset -R modparam="/sys/module/zfs/parameters/zfs_fletcher_4_impl" if awk '/^flags/ {exit !/sse/}' /proc/cpuinfo; then log_must grep -q sse "$modparam" log_pass "SIMD instructions supported" From 242cf5b23a459a1ad05013bcc5e082cb3c5333b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 1 Apr 2022 20:36:30 +0200 Subject: [PATCH 2/6] linux: module: zfs: list out all authors and licences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only the last stanza is used for determining the licence, so this still TAINT_NON_GPLs Signed-off-by: Ahelenia Ziemiańska --- module/os/linux/zfs/zfs_ioctl_os.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/os/linux/zfs/zfs_ioctl_os.c b/module/os/linux/zfs/zfs_ioctl_os.c index 9465ef0632ba..c65702e1a053 100644 --- a/module/os/linux/zfs/zfs_ioctl_os.c +++ b/module/os/linux/zfs/zfs_ioctl_os.c @@ -322,5 +322,8 @@ MODULE_ALIAS("zcommon"); MODULE_ALIAS("zzstd"); MODULE_DESCRIPTION("ZFS"); MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE("Lua: MIT"); +MODULE_LICENSE("zstd: Dual BSD/GPL"); +MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE(ZFS_META_LICENSE); MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); From 990ec70702f2c6ed93a6b75112c532b88a796daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 4 Apr 2022 12:48:47 +0200 Subject: [PATCH 3/6] scripts: zfs.sh: remove cat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/zfs.sh b/scripts/zfs.sh index 5689d2576a18..fe34777523af 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -75,7 +75,7 @@ done kill_zed() { if [ -f "$ZED_PIDFILE" ]; then - PID=$(cat "$ZED_PIDFILE") + read -r PID <"$ZED_PIDFILE" kill "$PID" fi } @@ -234,8 +234,7 @@ stack_check_linux() { STACK_LIMIT=15362 if [ -e "$STACK_MAX_SIZE" ]; then - STACK_SIZE=$(cat "$STACK_MAX_SIZE") - + read -r STACK_SIZE <"$STACK_MAX_SIZE" if [ "$STACK_SIZE" -ge "$STACK_LIMIT" ]; then echo echo "Warning: max stack size $STACK_SIZE bytes" From 57975541d8c208523d74c9cf61f216cec57e79dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 4 Apr 2022 12:55:41 +0200 Subject: [PATCH 4/6] scripts: zfs.sh: make usage make sense MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't pass the arguments as arguments Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs.sh | 58 +++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/scripts/zfs.sh b/scripts/zfs.sh index fe34777523af..66405b22f5d0 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -3,7 +3,7 @@ # A simple script to load/unload the ZFS module stack. # -BASE_DIR=$(dirname "$0") +BASE_DIR=${0%/*} SCRIPT_COMMON=common.sh if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then . "${BASE_DIR}/${SCRIPT_COMMON}" @@ -11,7 +11,6 @@ else echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 fi -PROG=zfs.sh VERBOSE="no" UNLOAD="no" LOAD="yes" @@ -28,28 +27,25 @@ KMOD_FREEBSD=${KMOD_FREEBSD:-openzfs} usage() { -cat << EOF + cat << EOF USAGE: -$0 [hvudS] [module-options] +$0 [hvudS] DESCRIPTION: Load/unload the ZFS module stack. OPTIONS: - -h Show this message - -v Verbose + -h Show this message + -v Verbose -r Reload modules - -u Unload modules - -S Enable kernel stack tracer + -u Unload modules + -S Enable kernel stack tracer EOF + exit 1 } while getopts 'hvruS' OPTION; do case $OPTION in - h) - usage - exit 1 - ;; v) VERBOSE="yes" ;; @@ -64,14 +60,13 @@ while getopts 'hvruS' OPTION; do S) STACK_TRACER="yes" ;; - ?) - usage - exit - ;; *) + usage ;; esac done +shift $(( OPTIND - 1 )) +[ $# -eq 0 ] || usage kill_zed() { if [ -f "$ZED_PIDFILE" ]; then @@ -98,7 +93,7 @@ check_modules_linux() { done if [ -n "$LOADED_MODULES" ]; then - printf "Unload the kernel modules by running '%s -u':\n" "$PROG" + printf "Unload the kernel modules by running '%s -u':\n" "$0" printf "%b" "$LOADED_MODULES" exit 1 fi @@ -115,10 +110,10 @@ check_modules_linux() { load_module_linux() { KMOD=$1 - FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') - VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') - if [ "$VERBOSE" = "yes" ]; then + FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') + VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') + echo "Loading: $FILE ($VERSION)" fi @@ -167,11 +162,12 @@ unload_module_linux() { NAME="${KMOD##*/}" NAME="${NAME%.ko}" - FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') - VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') if [ "$VERBOSE" = "yes" ]; then - echo "Unloading: $KMOD ($VERSION)" + FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') + VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') + + echo "Unloading: $FILE ($VERSION)" fi rmmod "$NAME" || echo "Failed to unload $NAME" @@ -255,15 +251,15 @@ if [ "$UNLOAD" = "yes" ]; then umount -t zfs -a case $UNAME in FreeBSD) - unload_modules_freebsd + unload_modules_freebsd ;; Linux) - stack_check_linux - unload_modules_linux + stack_check_linux + unload_modules_linux ;; *) - echo "unknown system: $UNAME" >&2 - exit 1 + echo "unknown system: $UNAME" >&2 + exit 1 ;; esac fi @@ -275,13 +271,13 @@ if [ "$LOAD" = "yes" ]; then Linux) stack_clear_linux check_modules_linux - load_modules_linux "$@" + load_modules_linux udevadm trigger udevadm settle ;; *) - echo "unknown system: $UNAME" >&2 - exit 1 + echo "unknown system: $UNAME" >&2 + exit 1 ;; esac fi From d36ca0c5ef8eff493677601732387381ebbe84c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 4 Apr 2022 13:08:59 +0200 Subject: [PATCH 5/6] scripts: zfs.sh: unload zfs with dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs.sh | 59 +++++++------------------------------------------- 1 file changed, 8 insertions(+), 51 deletions(-) diff --git a/scripts/zfs.sh b/scripts/zfs.sh index 66405b22f5d0..9ead0316d9ee 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -18,6 +18,7 @@ STACK_TRACER="no" ZED_PIDFILE=${ZED_PIDFILE:-/var/run/zed.pid} LDMOD=${LDMOD:-/sbin/modprobe} +DELMOD=${DELMOD:-/sbin/modprobe -r} KMOD_ZLIB_DEFLATE=${KMOD_ZLIB_DEFLATE:-zlib_deflate} KMOD_ZLIB_INFLATE=${KMOD_ZLIB_INFLATE:-zlib_inflate} @@ -110,10 +111,11 @@ check_modules_linux() { load_module_linux() { KMOD=$1 + FILE=$(modinfo "$KMOD" 2>&1 | awk 'NR == 1 && /zlib/ && /not found/ {print "(builtin)"; exit} /^filename:/ {print $2}') + [ "$FILE" = "(builtin)" ] && return + if [ "$VERBOSE" = "yes" ]; then - FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') - echo "Loading: $FILE ($VERSION)" fi @@ -138,15 +140,7 @@ load_modules_freebsd() { load_modules_linux() { mkdir -p /etc/zfs - if modinfo "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1; then - modprobe "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1 - fi - - if modinfo "$KMOD_ZLIB_INFLATE">/dev/null 2>&1; then - modprobe "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1 - fi - - for KMOD in $KMOD_SPL $KMOD_ZFS; do + for KMOD in "$KMOD_ZLIB_DEFLATE" "$KMOD_ZLIB_INFLATE" $KMOD_SPL $KMOD_ZFS; do load_module_linux "$KMOD" || return 1 done @@ -157,24 +151,6 @@ load_modules_linux() { return 0 } -unload_module_linux() { - KMOD=$1 - - NAME="${KMOD##*/}" - NAME="${NAME%.ko}" - - if [ "$VERBOSE" = "yes" ]; then - FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') - VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') - - echo "Unloading: $FILE ($VERSION)" - fi - - rmmod "$NAME" || echo "Failed to unload $NAME" - - return 0 -} - unload_modules_freebsd() { kldunload "$KMOD_FREEBSD" || echo "Failed to unload $KMOD_FREEBSD" @@ -186,32 +162,13 @@ unload_modules_freebsd() { } unload_modules_linux() { - for KMOD in $KMOD_ZFS $KMOD_SPL; do - NAME="${KMOD##*/}" - NAME="${NAME%.ko}" - USE_COUNT=$(lsmod | awk '/^'"${NAME}"'/ {print $3}') - - if [ "$USE_COUNT" = "0" ] ; then - unload_module_linux "$KMOD" || return 1 - elif [ "$USE_COUNT" != "" ] ; then - echo "Module ${NAME} is still in use!" - return 1 - fi - done - - if modinfo "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1; then - modprobe -r "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1 - fi - - if modinfo "$KMOD_ZLIB_INFLATE">/dev/null 2>&1; then - modprobe -r "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1 - fi + NAME="${KMOD_ZFS##*/}" + NAME="${NAME%.ko}" + $DELMOD "$NAME" || return if [ "$VERBOSE" = "yes" ]; then echo "Successfully unloaded ZFS module stack" fi - - return 0 } stack_clear_linux() { From adccba564a89171d1174a57ebd456a4033d3266b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 4 Apr 2022 13:16:31 +0200 Subject: [PATCH 6/6] linux: module: uninstall legacy modules on (un)installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can be reverted once we're sure nobody's using them anymore (post-3.0 release?) Signed-off-by: Ahelenia Ziemiańska --- module/Makefile.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/Makefile.in b/module/Makefile.in index 960cb7259bd6..ea83ba127d46 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -76,8 +76,12 @@ clean-FreeBSD: clean: clean-@ac_system@ +.PHONY: modules_uninstall-Linux-legacy +modules_uninstall-Linux-legacy: + $(RM) -r $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,spl/ avl/ icp/ lua/ nvpair/ unicode/ zcommon/ zfs/ zstd/) + KMODDIR := $(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ -modules_install-Linux: +modules_install-Linux: modules_uninstall-Linux-legacy @# Install the kernel modules $(MAKE) -C @LINUX_OBJ@ M="$$PWD" modules_install \ INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \ @@ -106,7 +110,7 @@ modules_install-FreeBSD: modules_install: modules_install-@ac_system@ -modules_uninstall-Linux: +modules_uninstall-Linux: modules_uninstall-Linux-legacy @# Uninstall the kernel modules $(RM) $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,zfs.ko spl.ko)