Cleanup linux module kbuild files
The linux module can be built either as an external module, or compiled
into the kernel, using copy-builtin. The source and build directories
are slightly different between the two cases, and currently, compiling
into the kernel still refers to some files from the configured ZFS
source tree, instead of the copies inside the kernel source tree. There
is also duplication between copy-builtin, which creates a Kbuild file to
build ZFS inside the kernel tree, and the top-level module/Makefile.in.
Fix this by moving the list of modules and the CFLAGS settings into a
new module/Kbuild.in, which will be used by the kernel kbuild
infrastructure, and using KBUILD_EXTMOD to distinguish the two cases
within the Makefiles, in order to choose appropriate include
directories etc.
Module CFLAGS setting is simplified by using subdir-ccflags-y (available
since 2.6.30) to set them in the top-level Kbuild instead of each
individual module. The disabling of -Wunused-but-set-variable is removed
from the lua and zfs modules. The variable that the Makefile uses is
actually not defined, so this has no effect; and the warning has long
been disabled by the kernel Makefile itself.
The target_cpu definition in module/{zfs,zcommon} is removed as it was
replaced by use of CONFIG_SPARC64 in
commit 70835c5b755e ("Unify target_cpu handling")
os/linux/{spl,zfs} are removed from obj-m, as they are not modules in
themselves, but are included by the Makefile in the spl and zfs module
directories. The vestigial Makefiles in os and os/linux are removed.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10379
Closes #10421
2020-06-08 00:03:12 +03:00
|
|
|
include Kbuild
|
2010-08-26 22:22:58 +04:00
|
|
|
|
2013-02-17 23:05:11 +04:00
|
|
|
INSTALL_MOD_DIR ?= extra
|
2021-10-01 20:44:34 +03:00
|
|
|
INSTALL_MOD_PATH ?= $(DESTDIR)
|
2013-02-17 23:05:11 +04:00
|
|
|
|
Add zstd support to zfs
This PR adds two new compression types, based on ZStandard:
- zstd: A basic ZStandard compression algorithm Available compression.
Levels for zstd are zstd-1 through zstd-19, where the compression
increases with every level, but speed decreases.
- zstd-fast: A faster version of the ZStandard compression algorithm
zstd-fast is basically a "negative" level of zstd. The compression
decreases with every level, but speed increases.
Available compression levels for zstd-fast:
- zstd-fast-1 through zstd-fast-10
- zstd-fast-20 through zstd-fast-100 (in increments of 10)
- zstd-fast-500 and zstd-fast-1000
For more information check the man page.
Implementation details:
Rather than treat each level of zstd as a different algorithm (as was
done historically with gzip), the block pointer `enum zio_compress`
value is simply zstd for all levels, including zstd-fast, since they all
use the same decompression function.
The compress= property (a 64bit unsigned integer) uses the lower 7 bits
to store the compression algorithm (matching the number of bits used in
a block pointer, as the 8th bit was borrowed for embedded block
pointers). The upper bits are used to store the compression level.
It is necessary to be able to determine what compression level was used
when later reading a block back, so the concept used in LZ4, where the
first 32bits of the on-disk value are the size of the compressed data
(since the allocation is rounded up to the nearest ashift), was
extended, and we store the version of ZSTD and the level as well as the
compressed size. This value is returned when decompressing a block, so
that if the block needs to be recompressed (L2ARC, nop-write, etc), that
the same parameters will be used to result in the matching checksum.
All of the internal ZFS code ( `arc_buf_hdr_t`, `objset_t`,
`zio_prop_t`, etc.) uses the separated _compress and _complevel
variables. Only the properties ZAP contains the combined/bit-shifted
value. The combined value is split when the compression_changed_cb()
callback is called, and sets both objset members (os_compress and
os_complevel).
The userspace tools all use the combined/bit-shifted value.
Additional notes:
zdb can now also decode the ZSTD compression header (flag -Z) and
inspect the size, version and compression level saved in that header.
For each record, if it is ZSTD compressed, the parameters of the decoded
compression header get printed.
ZSTD is included with all current tests and new tests are added
as-needed.
Per-dataset feature flags now get activated when the property is set.
If a compression algorithm requires a feature flag, zfs activates the
feature when the property is set, rather than waiting for the first
block to be born. This is currently only used by zstd but can be
extended as needed.
Portions-Sponsored-By: The FreeBSD Foundation
Co-authored-by: Allan Jude <allanjude@freebsd.org>
Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Co-authored-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Allan Jude <allanjude@freebsd.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Closes #6247
Closes #9024
Closes #10277
Closes #10278
2020-08-18 20:10:17 +03:00
|
|
|
SUBDIR_TARGETS = icp lua zstd
|
2016-05-12 17:51:24 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
all: modules
|
|
|
|
distclean maintainer-clean: clean
|
|
|
|
install: modules_install
|
|
|
|
uninstall: modules_uninstall
|
|
|
|
check:
|
|
|
|
|
Fix tags targets in module/Makefile.in + cleanup
These targets look to have been copied from an automake-generated
Makefile.in, and can't work since none of the auto-generated automake
variables are defined here.
Moreover, ctags has been overridden in the top-level Makefile, so the
target is pointless anyway, and gtags is not a recursive target.
Fix cscopelist by moving it to the top-level Makefile as well, in line
with ctags and etags.
Also, add -a to ctags command as well, otherwise it won't work if more
than one xargs invocation takes place.
Add assembler files to ctags/etags, prune all dotted-dirs, and restrict
the find to files only.
Cleanup: add .PHONY to module/Makefile.in, and fix one recipe with a
missing continuation character.
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10493
2020-06-22 05:13:02 +03:00
|
|
|
.PHONY: all distclean maintainer-clean install uninstall check distdir \
|
|
|
|
modules modules-Linux modules-FreeBSD modules-unknown \
|
|
|
|
clean clean-Linux clean-FreeBSD \
|
|
|
|
modules_install modules_install-Linux modules_install-FreeBSD \
|
2021-01-22 23:54:34 +03:00
|
|
|
modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD \
|
|
|
|
cppcheck cppcheck-Linux cppcheck-FreeBSD
|
Fix tags targets in module/Makefile.in + cleanup
These targets look to have been copied from an automake-generated
Makefile.in, and can't work since none of the auto-generated automake
variables are defined here.
Moreover, ctags has been overridden in the top-level Makefile, so the
target is pointless anyway, and gtags is not a recursive target.
Fix cscopelist by moving it to the top-level Makefile as well, in line
with ctags and etags.
Also, add -a to ctags command as well, otherwise it won't work if more
than one xargs invocation takes place.
Add assembler files to ctags/etags, prune all dotted-dirs, and restrict
the find to files only.
Cleanup: add .PHONY to module/Makefile.in, and fix one recipe with a
missing continuation character.
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10493
2020-06-22 05:13:02 +03:00
|
|
|
|
2021-03-05 23:16:41 +03:00
|
|
|
# For FreeBSD, use debug options from ./configure if not overridden.
|
|
|
|
export WITH_DEBUG ?= @WITH_DEBUG@
|
|
|
|
export WITH_INVARIANTS ?= @WITH_INVARIANTS@
|
|
|
|
|
2020-06-19 20:33:56 +03:00
|
|
|
# Filter out options that FreeBSD make doesn't understand
|
|
|
|
getflags = ( \
|
|
|
|
set -- \
|
|
|
|
$(filter-out --%,$(firstword $(MFLAGS))) \
|
|
|
|
$(filter -I%,$(MFLAGS)) \
|
|
|
|
$(filter -j%,$(MFLAGS)); \
|
|
|
|
fmakeflags=""; \
|
|
|
|
while getopts :deiI:j:knqrstw flag; do \
|
|
|
|
case $$flag in \
|
|
|
|
\?) :;; \
|
|
|
|
:) if [ $$OPTARG = "j" ]; then \
|
|
|
|
ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \
|
|
|
|
if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \
|
|
|
|
fi;; \
|
|
|
|
d) fmakeflags="$$fmakeflags -dA";; \
|
|
|
|
*) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \
|
|
|
|
esac; \
|
|
|
|
done; \
|
|
|
|
echo $$fmakeflags \
|
|
|
|
)
|
|
|
|
FMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags))
|
|
|
|
|
|
|
|
ifneq (@abs_srcdir@,@abs_builddir@)
|
|
|
|
FMAKEFLAGS += MAKEOBJDIR=@abs_builddir@
|
|
|
|
endif
|
2021-03-05 23:16:41 +03:00
|
|
|
|
2020-06-19 20:33:56 +03:00
|
|
|
FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS)
|
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules-Linux:
|
2016-05-12 17:51:24 +03:00
|
|
|
list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
|
|
|
|
$(MAKE) -C $$targetdir; \
|
|
|
|
done
|
2019-09-06 21:26:26 +03:00
|
|
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
|
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
modules-FreeBSD:
|
2020-06-19 20:33:56 +03:00
|
|
|
+$(FMAKE)
|
2020-04-14 21:36:28 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules-unknown:
|
|
|
|
@true
|
|
|
|
|
|
|
|
modules: modules-@ac_system@
|
2010-08-26 22:22:58 +04:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
clean-Linux:
|
2011-04-06 00:13:01 +04:00
|
|
|
@# Only cleanup the kernel build directories when CONFIG_KERNEL
|
|
|
|
@# is defined. This indicates that kernel modules should be built.
|
2019-09-06 21:26:26 +03:00
|
|
|
@CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ clean
|
2011-04-06 00:13:01 +04:00
|
|
|
|
2010-08-26 22:22:58 +04:00
|
|
|
if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
|
|
|
|
if [ -f Module.markers ]; then $(RM) Module.markers; fi
|
|
|
|
|
2018-05-14 04:59:02 +03:00
|
|
|
find . -name '*.ur-safe' -type f -print | xargs $(RM)
|
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
clean-FreeBSD:
|
2020-06-19 20:33:56 +03:00
|
|
|
+$(FMAKE) clean
|
2020-04-14 21:36:28 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
clean: clean-@ac_system@
|
|
|
|
|
|
|
|
modules_install-Linux:
|
2010-09-05 00:26:23 +04:00
|
|
|
@# Install the kernel modules
|
2019-09-06 21:26:26 +03:00
|
|
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \
|
2021-10-01 20:44:34 +03:00
|
|
|
INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
|
2014-10-22 22:02:45 +04:00
|
|
|
INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
|
|
|
|
KERNELRELEASE=@LINUX_VERSION@
|
2011-07-20 08:44:07 +04:00
|
|
|
@# Remove extraneous build products when packaging
|
2021-10-01 20:44:34 +03:00
|
|
|
kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
|
2015-11-20 04:42:41 +03:00
|
|
|
if [ -n "$(DESTDIR)" ]; then \
|
2013-02-17 23:05:11 +04:00
|
|
|
find $$kmoddir -name 'modules.*' | xargs $(RM); \
|
2011-07-20 08:44:07 +04:00
|
|
|
fi
|
2021-10-01 20:44:34 +03:00
|
|
|
sysmap=$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
|
2010-08-26 22:22:58 +04:00
|
|
|
if [ -f $$sysmap ]; then \
|
|
|
|
depmod -ae -F $$sysmap @LINUX_VERSION@; \
|
|
|
|
fi
|
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
modules_install-FreeBSD:
|
|
|
|
@# Install the kernel modules
|
2020-06-19 20:33:56 +03:00
|
|
|
+$(FMAKE) install
|
2020-04-14 21:36:28 +03:00
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules_install: modules_install-@ac_system@
|
|
|
|
|
|
|
|
modules_uninstall-Linux:
|
2010-09-05 00:26:23 +04:00
|
|
|
@# Uninstall the kernel modules
|
2021-10-01 20:44:34 +03:00
|
|
|
kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
|
2020-06-25 21:04:50 +03:00
|
|
|
for objdir in $(ZFS_MODULES); do \
|
2019-08-20 01:22:52 +03:00
|
|
|
$(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
|
2013-02-17 23:05:11 +04:00
|
|
|
done
|
2010-08-26 22:22:58 +04:00
|
|
|
|
2020-04-14 21:36:28 +03:00
|
|
|
modules_uninstall-FreeBSD:
|
|
|
|
@false
|
|
|
|
|
2019-09-06 21:26:26 +03:00
|
|
|
modules_uninstall: modules_uninstall-@ac_system@
|
|
|
|
|
2021-01-22 23:54:34 +03:00
|
|
|
cppcheck-Linux:
|
|
|
|
@CPPCHECK@ -j@CPU_COUNT@ --std=c99 --quiet --force --error-exitcode=2 \
|
|
|
|
--inline-suppr --suppress=noValidConfiguration \
|
|
|
|
--enable=warning,information -D_KERNEL \
|
|
|
|
--include=@LINUX_OBJ@/include/generated/autoconf.h \
|
|
|
|
--include=@top_srcdir@/zfs_config.h \
|
|
|
|
--config-exclude=@LINUX_OBJ@/include \
|
|
|
|
-I @LINUX_OBJ@/include \
|
|
|
|
-I @top_srcdir@/include/os/linux/kernel \
|
|
|
|
-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
|
|
|
|
|
|
|
|
cppcheck-FreeBSD:
|
|
|
|
@true
|
|
|
|
|
|
|
|
cppcheck: cppcheck-@ac_system@
|
|
|
|
|
2010-08-26 22:22:58 +04:00
|
|
|
distdir:
|
2020-06-25 21:04:50 +03:00
|
|
|
(cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \
|
|
|
|
while read path; do \
|
|
|
|
mkdir -p $$distdir/$${path%/*}; \
|
|
|
|
cp @srcdir@/$$path $$distdir/$$path; \
|
|
|
|
done; \
|
|
|
|
cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd
|