Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107569634
D26218.id77469.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
26 KB
Referenced Files
None
Subscribers
None
D26218.id77469.diff
View Options
Index: stand/efi/boot1/Makefile
===================================================================
--- stand/efi/boot1/Makefile
+++ stand/efi/boot1/Makefile
@@ -40,6 +40,7 @@
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
Index: stand/libsa/zfs/Makefile.inc
===================================================================
--- stand/libsa/zfs/Makefile.inc
+++ 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
Index: stand/libsa/zfs/zfsimpl.c
===================================================================
--- stand/libsa/zfs/zfsimpl.c
+++ stand/libsa/zfs/zfsimpl.c
@@ -42,6 +42,7 @@
#include "zfsimpl.h"
#include "zfssubr.c"
+extern int zstd_init(void);
struct zfsmount {
const spa_t *spa;
@@ -112,6 +113,7 @@
*/
static const char *features_for_read[] = {
"org.illumos:lz4_compress",
+ "org.freebsd:zstd_compress",
"com.delphix:hole_birth",
"com.delphix:extensible_dataset",
"com.delphix:embedded_data",
@@ -170,6 +172,7 @@
dnode_cache_buf = malloc(SPA_MAXBLOCKSIZE);
zfs_init_crc();
+ zstd_init();
}
static int
Index: stand/libsa/zfs/zstd_shim.c
===================================================================
--- /dev/null
+++ stand/libsa/zfs/zstd_shim.c
@@ -0,0 +1,52 @@
+/*
+ * define hearder guards that we need to turn off in this environment...
+ */
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/debug.h>
+#include <sys/proc.h>
+#include <sys/time.h>
+#include <sys/mutex.h>
+#include <sys/byteorder.h>
+
+typedef int krw_t;
+u_int cpu_feature;
+
+#define M_WAITOK 0
+#define M_ZERO 0
+#define M_NOWAIT 0
+#define MALLOC_DECLARE(x)
+#define KM_SLEEP 0
+
+extern void Free(void *p, char *file, int line);
+extern void *Malloc(size_t bytes, char *file, int line);
+#define zfs_kmem_free(p, size) Free(p, __FILE__, __LINE__)
+#define zfs_kmem_alloc(size, flags) Malloc((size), __FILE__, __LINE__)
+#define kmem_zalloc(size, flags) Malloc((size), __FILE__, __LINE__)
+#define kmem_free(p, size) Free(p, __FILE__, __LINE__)
+
+int mp_ncpus = 1;
+volatile time_t time_second = 1;
+
+typedef int boolean_t;
+
+#define sx_xlock(s) (1)
+#define sx_try_xlock(s) (1)
+#define sx_xunlock(s) (1)
+#define SX_DUPOK 0
+#define SX_NEW 0
+#define SX_NOWITNESS 0
+
+void
+sx_init_flags(struct sx *sx, const char *description, int opts)
+{
+
+}
+
+void
+sx_destroy(struct sx *sx)
+{
+
+}
+
+#include <contrib/openzfs/module/zstd/zfs_zstd.c>
Index: sys/cddl/boot/zfs/zfsimpl.h
===================================================================
--- sys/cddl/boot/zfs/zfsimpl.h
+++ sys/cddl/boot/zfs/zfsimpl.h
@@ -611,9 +611,63 @@
ZIO_COMPRESS_GZIP_9,
ZIO_COMPRESS_ZLE,
ZIO_COMPRESS_LZ4,
+ ZIO_COMPRESS_ZSTD,
ZIO_COMPRESS_FUNCTIONS
};
+enum zio_zstd_levels {
+ ZIO_ZSTD_LEVEL_INHERIT = 0,
+ ZIO_ZSTD_LEVEL_1,
+#define ZIO_ZSTD_LEVEL_MIN ZIO_ZSTD_LEVEL_1
+ ZIO_ZSTD_LEVEL_2,
+ ZIO_ZSTD_LEVEL_3,
+#define ZIO_ZSTD_LEVEL_DEFAULT ZIO_ZSTD_LEVEL_3
+ ZIO_ZSTD_LEVEL_4,
+ ZIO_ZSTD_LEVEL_5,
+ ZIO_ZSTD_LEVEL_6,
+ ZIO_ZSTD_LEVEL_7,
+ ZIO_ZSTD_LEVEL_8,
+ ZIO_ZSTD_LEVEL_9,
+ ZIO_ZSTD_LEVEL_10,
+ ZIO_ZSTD_LEVEL_11,
+ ZIO_ZSTD_LEVEL_12,
+ ZIO_ZSTD_LEVEL_13,
+ ZIO_ZSTD_LEVEL_14,
+ ZIO_ZSTD_LEVEL_15,
+ ZIO_ZSTD_LEVEL_16,
+ ZIO_ZSTD_LEVEL_17,
+ ZIO_ZSTD_LEVEL_18,
+ ZIO_ZSTD_LEVEL_19,
+#define ZIO_ZSTD_LEVEL_MAX ZIO_ZSTD_LEVEL_19
+ ZIO_ZSTD_LEVEL_RESERVE = 101, /* Leave room for new positive levels */
+ ZIO_ZSTD_LEVEL_FAST, /* Fast levels are negative */
+ ZIO_ZSTD_LEVEL_FAST_1,
+#define ZIO_ZSTD_LEVEL_FAST_DEFAULT ZIO_ZSTD_LEVEL_FAST_1
+ ZIO_ZSTD_LEVEL_FAST_2,
+ ZIO_ZSTD_LEVEL_FAST_3,
+ ZIO_ZSTD_LEVEL_FAST_4,
+ ZIO_ZSTD_LEVEL_FAST_5,
+ ZIO_ZSTD_LEVEL_FAST_6,
+ ZIO_ZSTD_LEVEL_FAST_7,
+ ZIO_ZSTD_LEVEL_FAST_8,
+ ZIO_ZSTD_LEVEL_FAST_9,
+ ZIO_ZSTD_LEVEL_FAST_10,
+ ZIO_ZSTD_LEVEL_FAST_20,
+ ZIO_ZSTD_LEVEL_FAST_30,
+ ZIO_ZSTD_LEVEL_FAST_40,
+ ZIO_ZSTD_LEVEL_FAST_50,
+ ZIO_ZSTD_LEVEL_FAST_60,
+ ZIO_ZSTD_LEVEL_FAST_70,
+ ZIO_ZSTD_LEVEL_FAST_80,
+ ZIO_ZSTD_LEVEL_FAST_90,
+ ZIO_ZSTD_LEVEL_FAST_100,
+ ZIO_ZSTD_LEVEL_FAST_500,
+ ZIO_ZSTD_LEVEL_FAST_1000,
+#define ZIO_ZSTD_LEVEL_FAST_MAX ZIO_ZSTD_LEVEL_FAST_1000
+ ZIO_ZSTD_LEVEL_AUTO = 251, /* Reserved for future use */
+ ZIO_ZSTD_LEVEL_LEVELS
+};
+
#define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB
#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF
Index: sys/cddl/boot/zfs/zfssubr.c
===================================================================
--- sys/cddl/boot/zfs/zfssubr.c
+++ sys/cddl/boot/zfs/zfssubr.c
@@ -30,8 +30,6 @@
static uint64_t zfs_crc64_table[256];
-#define ECKSUM 666
-
#define ASSERT3S(x, y, z) ((void)0)
#define ASSERT3U(x, y, z) ((void)0)
#define ASSERT3P(x, y, z) ((void)0)
@@ -107,6 +105,10 @@
#include "sha256.c"
#include "skein_zfs.c"
+extern int zfs_zstd_decompress(void *s_start, void *d_start, size_t s_len,
+ size_t d_len, int n);
+
+
static zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
{{NULL, NULL}, NULL, NULL, 0, "inherit"},
{{NULL, NULL}, NULL, NULL, 0, "on"},
@@ -181,6 +183,7 @@
{NULL, NULL, 9, "gzip-9"},
{NULL, zle_decompress, 64, "zle"},
{NULL, lz4_decompress, 0, "lz4"},
+ {NULL, zfs_zstd_decompress, ZIO_ZSTD_LEVEL_DEFAULT, "zstd"}
};
static void
Index: sys/cddl/contrib/opensolaris/uts/common/os/list.c
===================================================================
--- sys/cddl/contrib/opensolaris/uts/common/os/list.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Generic doubly-linked list implementation
- */
-
-#include <sys/list.h>
-#include <sys/list_impl.h>
-#include <sys/types.h>
-#include <sys/sysmacros.h>
-#include <sys/debug.h>
-
-#define list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
-#define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
-#define list_empty(a) ((a)->list_head.list_next == &(a)->list_head)
-
-#define list_insert_after_node(list, node, object) { \
- list_node_t *lnew = list_d2l(list, object); \
- lnew->list_prev = (node); \
- lnew->list_next = (node)->list_next; \
- (node)->list_next->list_prev = lnew; \
- (node)->list_next = lnew; \
-}
-
-#define list_insert_before_node(list, node, object) { \
- list_node_t *lnew = list_d2l(list, object); \
- lnew->list_next = (node); \
- lnew->list_prev = (node)->list_prev; \
- (node)->list_prev->list_next = lnew; \
- (node)->list_prev = lnew; \
-}
-
-#define list_remove_node(node) \
- (node)->list_prev->list_next = (node)->list_next; \
- (node)->list_next->list_prev = (node)->list_prev; \
- (node)->list_next = (node)->list_prev = NULL
-
-void
-list_create(list_t *list, size_t size, size_t offset)
-{
- ASSERT(list);
- ASSERT(size > 0);
- ASSERT(size >= offset + sizeof (list_node_t));
-
- list->list_size = size;
- list->list_offset = offset;
- list->list_head.list_next = list->list_head.list_prev =
- &list->list_head;
-}
-
-void
-list_destroy(list_t *list)
-{
- list_node_t *node = &list->list_head;
-
- ASSERT(list);
- ASSERT(list->list_head.list_next == node);
- ASSERT(list->list_head.list_prev == node);
-
- node->list_next = node->list_prev = NULL;
-}
-
-void
-list_insert_after(list_t *list, void *object, void *nobject)
-{
- if (object == NULL) {
- list_insert_head(list, nobject);
- } else {
- list_node_t *lold = list_d2l(list, object);
- list_insert_after_node(list, lold, nobject);
- }
-}
-
-void
-list_insert_before(list_t *list, void *object, void *nobject)
-{
- if (object == NULL) {
- list_insert_tail(list, nobject);
- } else {
- list_node_t *lold = list_d2l(list, object);
- list_insert_before_node(list, lold, nobject);
- }
-}
-
-void
-list_insert_head(list_t *list, void *object)
-{
- list_node_t *lold = &list->list_head;
- list_insert_after_node(list, lold, object);
-}
-
-void
-list_insert_tail(list_t *list, void *object)
-{
- list_node_t *lold = &list->list_head;
- list_insert_before_node(list, lold, object);
-}
-
-void
-list_remove(list_t *list, void *object)
-{
- list_node_t *lold = list_d2l(list, object);
- ASSERT(!list_empty(list));
- ASSERT(lold->list_next != NULL);
- list_remove_node(lold);
-}
-
-void *
-list_remove_head(list_t *list)
-{
- list_node_t *head = list->list_head.list_next;
- if (head == &list->list_head)
- return (NULL);
- list_remove_node(head);
- return (list_object(list, head));
-}
-
-void *
-list_remove_tail(list_t *list)
-{
- list_node_t *tail = list->list_head.list_prev;
- if (tail == &list->list_head)
- return (NULL);
- list_remove_node(tail);
- return (list_object(list, tail));
-}
-
-void *
-list_head(list_t *list)
-{
- if (list_empty(list))
- return (NULL);
- return (list_object(list, list->list_head.list_next));
-}
-
-void *
-list_tail(list_t *list)
-{
- if (list_empty(list))
- return (NULL);
- return (list_object(list, list->list_head.list_prev));
-}
-
-void *
-list_next(list_t *list, void *object)
-{
- list_node_t *node = list_d2l(list, object);
-
- if (node->list_next != &list->list_head)
- return (list_object(list, node->list_next));
-
- return (NULL);
-}
-
-void *
-list_prev(list_t *list, void *object)
-{
- list_node_t *node = list_d2l(list, object);
-
- if (node->list_prev != &list->list_head)
- return (list_object(list, node->list_prev));
-
- return (NULL);
-}
-
-/*
- * Insert src list after dst list. Empty src list thereafter.
- */
-void
-list_move_tail(list_t *dst, list_t *src)
-{
- list_node_t *dstnode = &dst->list_head;
- list_node_t *srcnode = &src->list_head;
-
- ASSERT(dst->list_size == src->list_size);
- ASSERT(dst->list_offset == src->list_offset);
-
- if (list_empty(src))
- return;
-
- dstnode->list_prev->list_next = srcnode->list_next;
- srcnode->list_next->list_prev = dstnode->list_prev;
- dstnode->list_prev = srcnode->list_prev;
- srcnode->list_prev->list_next = dstnode;
-
- /* empty src list */
- srcnode->list_next = srcnode->list_prev = srcnode;
-}
-
-void
-list_link_replace(list_node_t *lold, list_node_t *lnew)
-{
- ASSERT(list_link_active(lold));
- ASSERT(!list_link_active(lnew));
-
- lnew->list_next = lold->list_next;
- lnew->list_prev = lold->list_prev;
- lold->list_prev->list_next = lnew;
- lold->list_next->list_prev = lnew;
- lold->list_next = lold->list_prev = NULL;
-}
-
-void
-list_link_init(list_node_t *link)
-{
- link->list_next = NULL;
- link->list_prev = NULL;
-}
-
-int
-list_link_active(list_node_t *link)
-{
- return (link->list_next != NULL);
-}
-
-int
-list_is_empty(list_t *list)
-{
- return (list_empty(list));
-}
Index: sys/contrib/openzfs/include/os/freebsd/linux/compiler.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/linux/compiler.h
+++ sys/contrib/openzfs/include/os/freebsd/linux/compiler.h
@@ -68,7 +68,7 @@
#define noinline __noinline
#define ____cacheline_aligned __aligned(CACHE_LINE_SIZE)
-#ifndef _KERNEL
+#if !defined(_KERNEL) && !defined(_STANDALONE)
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
Index: sys/contrib/openzfs/include/os/freebsd/spl/rpc/xdr.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/rpc/xdr.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/rpc/xdr.h
@@ -33,7 +33,7 @@
#include <rpc/types.h>
#include_next <rpc/xdr.h>
-#ifndef _KERNEL
+#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <assert.h>
@@ -66,6 +66,6 @@
xdrmem_control((xdrs), (req), (op)) : \
(*(xdrs)->x_ops->x_control)(xdrs, req, op))
-#endif /* !_KERNEL */
+#endif /* !_KERNEL && !_STANDALONE */
#endif /* !_OPENSOLARIS_RPC_XDR_H_ */
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/atomic.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/atomic.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/atomic.h
@@ -34,7 +34,7 @@
#define atomic_sub_64 atomic_subtract_64
-#if defined(__i386__) && (defined(_KERNEL) || defined(KLD_MODULE))
+#if defined(__i386__) && (defined(_KERNEL) || defined(KLD_MODULE) || defined(_STANDALONE))
#define I386_HAVE_ATOMIC64
#endif
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/byteorder.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/byteorder.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/byteorder.h
@@ -80,6 +80,7 @@
#define BE_64(x) BSWAP_64(x)
#endif
+#if !defined(_STANDALONE)
#if BYTE_ORDER == _BIG_ENDIAN
#define htonll(x) BMASK_64(x)
#define ntohll(x) BMASK_64(x)
@@ -101,6 +102,7 @@
#define ntohll(x) BSWAP_64(x)
#endif
#endif
+#endif
#define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa)))
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
@@ -113,7 +113,7 @@
#define __VPRINTFLIKE(__n) __sun_attr__((__VPRINTFLIKE__(__n)))
#define __KPRINTFLIKE(__n) __sun_attr__((__KPRINTFLIKE__(__n)))
#define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n)))
-#ifdef _KERNEL
+#if defined(_KERNEL)
#define __NORETURN __sun_attr__((__noreturn__))
#endif
#define __CONST __sun_attr__((__const__))
@@ -174,7 +174,7 @@
#define __exit
#endif
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(_STANDALONE)
#define param_set_charp(a, b) (0)
#define ATTR_UID AT_UID
#define ATTR_GID AT_GID
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/cmn_err.h
@@ -52,42 +52,33 @@
/*PRINTFLIKE2*/
extern void cmn_err(int, const char *, ...)
__KPRINTFLIKE(2);
-#pragma rarely_called(cmn_err)
extern void vzcmn_err(zoneid_t, int, const char *, __va_list)
__KVPRINTFLIKE(3);
-#pragma rarely_called(vzcmn_err)
extern void vcmn_err(int, const char *, __va_list)
__KVPRINTFLIKE(2);
-#pragma rarely_called(vcmn_err)
/*PRINTFLIKE3*/
extern void zcmn_err(zoneid_t, int, const char *, ...)
__KPRINTFLIKE(3);
-#pragma rarely_called(zcmn_err)
extern void vzprintf(zoneid_t, const char *, __va_list)
__KVPRINTFLIKE(2);
-#pragma rarely_called(vzprintf)
/*PRINTFLIKE2*/
extern void zprintf(zoneid_t, const char *, ...)
__KPRINTFLIKE(2);
-#pragma rarely_called(zprintf)
extern void vuprintf(const char *, __va_list)
__KVPRINTFLIKE(1);
-#pragma rarely_called(vuprintf)
/*PRINTFLIKE1*/
extern void panic(const char *, ...)
__KPRINTFLIKE(1) __NORETURN;
-#pragma rarely_called(panic)
extern void vpanic(const char *, __va_list)
__KVPRINTFLIKE(1) __NORETURN;
-#pragma rarely_called(vpanic)
#endif /* !_ASM */
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h
@@ -36,6 +36,7 @@
#include <sys/spl_condvar.h>
#include <sys/mutex.h>
#include <sys/time.h>
+#include <sys/errno.h>
/*
* cv_timedwait() is similar to cv_wait() except that it additionally expects
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/kmem.h
@@ -29,6 +29,7 @@
#ifndef _OPENSOLARIS_SYS_KMEM_H_
#define _OPENSOLARIS_SYS_KMEM_H_
+#ifdef _KERNEL
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/vmem.h>
@@ -93,5 +94,5 @@
zfs_kmem_alloc((size), (kmflags) | M_ZERO)
#define kmem_free(buf, size) zfs_kmem_free((buf), (size))
-
+#endif
#endif /* _OPENSOLARIS_SYS_KMEM_H_ */
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h
@@ -121,7 +121,6 @@
size_t ks_raw_bufsize; /* size of raw ops buffer */
struct sysctl_ctx_list ks_sysctl_ctx;
struct sysctl_oid *ks_sysctl_root;
-
};
typedef struct kstat_named_s {
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h
@@ -41,7 +41,7 @@
#include <sys/kmem.h>
#include <sys/malloc.h>
-
+#ifdef _KERNEL
#define CPU curcpu
#define minclsyspri PRIBIO
#define defclsyspri minclsyspri
@@ -111,4 +111,5 @@
return (p == curproc);
}
+#endif
#endif /* _OPENSOLARIS_SYS_PROC_H_ */
Index: sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/sysmacros.h
@@ -319,7 +319,7 @@
/* avoid any possibility of clashing with <stddef.h> version */
-#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
+#define offsetof(type, field) __offsetof(type, field)
#endif
/*
Index: sys/contrib/openzfs/include/sys/zfs_context.h
===================================================================
--- sys/contrib/openzfs/include/sys/zfs_context.h
+++ sys/contrib/openzfs/include/sys/zfs_context.h
@@ -32,7 +32,7 @@
extern "C" {
#endif
-#ifdef __KERNEL__
+#if defined(__KERNEL__) || defined(_STANDALONE)
#include <sys/note.h>
#include <sys/types.h>
#include <sys/atomic.h>
Index: sys/contrib/openzfs/include/sys/zio_compress.h
===================================================================
--- sys/contrib/openzfs/include/sys/zio_compress.h
+++ sys/contrib/openzfs/include/sys/zio_compress.h
@@ -30,7 +30,9 @@
#ifndef _SYS_ZIO_COMPRESS_H
#define _SYS_ZIO_COMPRESS_H
+#if !defined(_STANDALONE)
#include <sys/abd.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -134,6 +136,7 @@
typedef int zio_getlevel_func_t(void *src, size_t s_len, uint8_t *level);
+#if !defined(_STANDALONE)
/*
* Common signature for all zio decompress functions using an ABD as input.
* This is helpful if you have both compressed ARC and scatter ABDs enabled,
@@ -141,6 +144,8 @@
*/
typedef int zio_decompress_abd_func_t(abd_t *src, void *dst,
size_t s_len, size_t d_len, int);
+#endif
+
/*
* Information about each compression function.
*/
@@ -183,10 +188,12 @@
/*
* Compress and decompress data if necessary.
*/
+#if !defined(_STANDALONE)
extern size_t zio_compress_data(enum zio_compress c, abd_t *src, void *dst,
size_t s_len, uint8_t level);
extern int zio_decompress_data(enum zio_compress c, abd_t *src, void *dst,
size_t s_len, size_t d_len, uint8_t *level);
+#endif
extern int zio_decompress_data_buf(enum zio_compress c, void *src, void *dst,
size_t s_len, size_t d_len, uint8_t *level);
extern int zio_compress_to_feature(enum zio_compress comp);
Index: sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h
===================================================================
--- sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h
+++ sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h
@@ -45,9 +45,9 @@
*/
#define MAXNAMELEN 256
-#ifndef IN_BASE
-#define UID_NOBODY 60001 /* user ID no body */
-#define GID_NOBODY UID_NOBODY
+#ifdef IN_BASE
+#define UID_NOBODY 65534 /* user ID no body */
+#define GID_NOBODY 65534
#endif
#define UID_NOACCESS 60002 /* user ID no access */
Index: sys/contrib/openzfs/module/os/freebsd/spl/list.c
===================================================================
--- sys/contrib/openzfs/module/os/freebsd/spl/list.c
+++ sys/contrib/openzfs/module/os/freebsd/spl/list.c
@@ -27,10 +27,12 @@
* Generic doubly-linked list implementation
*/
+#include <sys/ccompile.h>
+#include <sys/types.h>
+#include <sys/param.h>
#include <sys/list.h>
#include <sys/list_impl.h>
#include <sys/types.h>
-#include <sys/sysmacros.h>
#include <sys/debug.h>
#define list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
Index: sys/contrib/openzfs/module/zstd/zfs_zstd.c
===================================================================
--- sys/contrib/openzfs/module/zstd/zfs_zstd.c
+++ sys/contrib/openzfs/module/zstd/zfs_zstd.c
@@ -41,15 +41,20 @@
#include <sys/param.h>
#include <sys/sysmacros.h>
+#if !defined(_STANDALONE)
#include <sys/zfs_context.h>
#include <sys/zio_compress.h>
#include <sys/spa.h>
+#else
+#include <sys/zio_compress.h>
+#endif
#include <sys/zstd/zstd.h>
#define ZSTD_STATIC_LINKING_ONLY
#include "lib/zstd.h"
#include "lib/zstd_errors.h"
+#if !defined(_STANDALONE)
kstat_t *zstd_ksp = NULL;
typedef struct zstd_stats {
@@ -75,6 +80,10 @@
{ "compress_failed", KSTAT_DATA_UINT64 },
{ "decompress_failed", KSTAT_DATA_UINT64 },
};
+#else
+#undef ZSTDSTAT_BUMP
+#define ZSTDSTAT_BUMP(x)
+#endif
/* Enums describing the allocator type specified by kmem_type in zstd_kmem */
enum zstd_kmem_type {
@@ -695,6 +704,7 @@
pool_count = (boot_ncpus * 4);
zstd_meminit();
+#if !defined(_STANDALONE)
/* Initialize kstat */
zstd_ksp = kstat_create("zfs", 0, "zstd", "misc",
KSTAT_TYPE_NAMED, sizeof (zstd_stats) / sizeof (kstat_named_t),
@@ -703,6 +713,7 @@
zstd_ksp->ks_data = &zstd_stats;
kstat_install(zstd_ksp);
}
+#endif
return (0);
}
@@ -710,12 +721,13 @@
extern void __exit
zstd_fini(void)
{
+#if !defined(_STANDALONE)
/* Deinitialize kstat */
if (zstd_ksp != NULL) {
kstat_delete(zstd_ksp);
zstd_ksp = NULL;
}
-
+#endif
/* Release fallback memory */
vmem_free(zstd_dctx_fallback.mem, zstd_dctx_fallback.mem_size);
mutex_destroy(&zstd_dctx_fallback.barrier);
Index: sys/sys/malloc.h
===================================================================
--- sys/sys/malloc.h
+++ sys/sys/malloc.h
@@ -37,6 +37,7 @@
#ifndef _SYS_MALLOC_H_
#define _SYS_MALLOC_H_
+#ifndef _STANDALONE
#include <sys/param.h>
#ifdef _KERNEL
#include <sys/systm.h>
@@ -267,4 +268,6 @@
#undef MUL_NO_OVERFLOW
#endif /* _KERNEL */
+#endif /* _STANDALONE */
+
#endif /* !_SYS_MALLOC_H_ */
Index: sys/sys/systm.h
===================================================================
--- sys/sys/systm.h
+++ sys/sys/systm.h
@@ -47,6 +47,7 @@
#include <sys/queue.h>
#include <sys/stdint.h> /* for people using printf mainly */
+#ifdef _KERNEL
__NULLABILITY_PRAGMA_PUSH
extern int cold; /* nonzero if we are doing a cold boot */
@@ -99,6 +100,7 @@
#define kassert_panic panic
#endif
#endif
+#endif /* KERNEL */
#ifdef INVARIANTS /* The option is always available */
#define KASSERT(exp,msg) do { \
@@ -135,12 +137,6 @@
#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
#endif
-#if defined(_KERNEL)
-#include <sys/param.h> /* MAXCPU */
-#include <sys/pcpu.h> /* curthread */
-#include <sys/kpilite.h>
-#endif
-
/*
* Helpful macros for quickly coming up with assertions with informative
* panic messages.
@@ -151,6 +147,18 @@
#define MPASS4(ex, what, file, line) \
KASSERT((ex), ("Assertion %s failed at %s:%d", what, file, line))
+/*
+ * Align variables.
+ */
+#define __read_mostly __section(".data.read_mostly")
+#define __read_frequently __section(".data.read_frequently")
+#define __exclusive_cache_line __aligned(CACHE_LINE_SIZE) \
+ __section(".data.exclusive_cache_line")
+#ifdef _KERNEL
+#include <sys/param.h> /* MAXCPU */
+#include <sys/pcpu.h> /* curthread */
+#include <sys/kpilite.h>
+
/*
* Assert that a pointer can be loaded from memory atomically.
*
@@ -180,13 +188,6 @@
})
#define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread)
-/*
- * Align variables.
- */
-#define __read_mostly __section(".data.read_mostly")
-#define __read_frequently __section(".data.read_frequently")
-#define __exclusive_cache_line __aligned(CACHE_LINE_SIZE) \
- __section(".data.exclusive_cache_line")
/*
* XXX the hints declarations are even more misplaced than most declarations
* in this file, since they are needed in one file (per arch) and only used
@@ -629,4 +630,5 @@
__NULLABILITY_PRAGMA_POP
+#endif
#endif /* !_SYS_SYSTM_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 17, 12:56 AM (7 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15831398
Default Alt Text
D26218.id77469.diff (26 KB)
Attached To
Mode
D26218: Integrate zstd into boot loader
Attached
Detach File
Event Timeline
Log In to Comment