aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2020-10-12 22:19:07 +0000
committerWarner Losh <imp@FreeBSD.org>2020-10-12 22:19:07 +0000
commit2fec3ae8964c8864a9e75d6a2f0ed137ede489a7 (patch)
tree802281ee096b50f2ca9590873e19f4623fad0c6a /stand
parente59db4685414e3fa23ac5c996d05708b678053ac (diff)
downloadsrc-2fec3ae8964c8864a9e75d6a2f0ed137ede489a7.tar.gz
src-2fec3ae8964c8864a9e75d6a2f0ed137ede489a7.zip
Add zstd support to the boot loader.
Add support to the _STANDALONE environment enough bits of the kernel that we can compile it. We still have a small zstd_shim.c since there were 3 items that were a bit hard to nail down and may be cleaned up in the future. These go hand in hand with a number of commits to sys/sys in the past weeks, should this need be MFCd. Discussed with: mmacy (in review and on IRC/Slack) Reviewed by: freqlabs (on openzfs repo) Differential Revision: https://reviews.freebsd.org/D26218
Notes
Notes: svn path=/head/; revision=366657
Diffstat (limited to 'stand')
-rw-r--r--stand/efi/boot1/Makefile1
-rw-r--r--stand/libsa/zfs/Makefile.inc26
-rw-r--r--stand/libsa/zfs/zfsimpl.c2
-rw-r--r--stand/libsa/zfs/zstd_shim.c40
4 files changed, 66 insertions, 3 deletions
diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile
index 0359dff00548..39dc4f8e70ad 100644
--- a/stand/efi/boot1/Makefile
+++ b/stand/efi/boot1/Makefile
@@ -40,6 +40,7 @@ CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include
CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/spl
CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4
+CFLAGS.zfs_module.c+= -include ${ZFSOSINC}/spl/sys/ccompile.h
CFLAGS+= -DEFI_ZFS_BOOT
.endif
diff --git a/stand/libsa/zfs/Makefile.inc b/stand/libsa/zfs/Makefile.inc
index 0b77f9a4cdb5..132d2abe63a6 100644
--- a/stand/libsa/zfs/Makefile.inc
+++ b/stand/libsa/zfs/Makefile.inc
@@ -1,17 +1,37 @@
# $FreeBSD$
.PATH: ${ZFSSRC}
-SRCS+= zfs.c nvlist.c skein.c skein_block.c list.c
.PATH: ${SYSDIR}/crypto/skein
-.PATH: ${SYSDIR}/cddl/contrib/opensolaris/uts/common/os
+.PATH: ${ZFSOSSRC}/spl
+.PATH: ${OZFS}/module/zstd/lib
+ZFSSRC= zfs.c nvlist.c skein.c skein_block.c list.c zstd_shim.c zstd.c
+SRCS+= ${ZFSSRC}
CFLAGS+= -I${LDRSRC}
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
-CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${SYSDIR}/crypto/skein
+ZFS_EARLY= -I${ZFSOSINC} \
+ -I${ZFSOSINC}/spl \
+ -I${ZFSOSINC}/zfs
+
+.for i in ${ZFSSRC}
+CFLAGS.$i+= -include ${ZFSOSINC}/spl/sys/ccompile.h
+.endfor
+
+CFLAGS_EARLY.list.c+= ${ZFS_EARLY}
+CFLAGS_EARLY.zstd_shim.c+= ${ZFS_EARLY}
+
+# Can't use the early flags because there's two conflicting definitions of boolean_t in
+# the zfs code that need to be unified.
+CFLAGS.nvlist.c+= -I${ZFSOSINC}/spl
+CFLAGS.zfs.c+= -I${ZFSOSINC}/spl \
+ -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
+CFLAGS.zstd_shim.c+= -DIN_BASE -I${OZFS}/include
+
# Do not unroll skein loops, reduce code size
CFLAGS.skein_block.c+= -DSKEIN_LOOP=111
+
CFLAGS+= -I${SYSDIR}/contrib/openzfs/include
CFLAGS+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
CFLAGS.zfs.c+= -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4
diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c
index 8b5cbc2feea9..0c2aa5ff3323 100644
--- a/stand/libsa/zfs/zfsimpl.c
+++ b/stand/libsa/zfs/zfsimpl.c
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include "zfsimpl.h"
#include "zfssubr.c"
+extern int zstd_init(void);
struct zfsmount {
const spa_t *spa;
@@ -170,6 +171,7 @@ zfs_init(void)
dnode_cache_buf = malloc(SPA_MAXBLOCKSIZE);
zfs_init_crc();
+ zstd_init();
}
static int
diff --git a/stand/libsa/zfs/zstd_shim.c b/stand/libsa/zfs/zstd_shim.c
new file mode 100644
index 000000000000..b94df6f51913
--- /dev/null
+++ b/stand/libsa/zfs/zstd_shim.c
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2020 M. Warner Losh <imp@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Small amount of shim code needed to get zfs_zstd.c to compile. These items
+ * here should all be defined in the SPL or as part of libstand somewhere, but
+ * aren't for reasons that haven't been tracked down yet. Ideally, they would
+ * all go away and we'd compile zfs_zstd.c directly. Based on an original by
+ * Matt Macey, but only the #include remains untouched from that.
+ */
+
+#define ZFS_MODULE_PARAM_ARGS void
+typedef int boolean_t; /* This one may be tough to get rid of */
+
+#include <contrib/openzfs/module/zstd/zfs_zstd.c>