Page MenuHomeFreeBSD

D26207.id76296.diff
No OneTemporary

D26207.id76296.diff

Index: stand/libsa/zfs/Makefile.inc
===================================================================
--- stand/libsa/zfs/Makefile.inc
+++ stand/libsa/zfs/Makefile.inc
@@ -3,15 +3,27 @@
.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: ${SYSDIR}/contrib/openzfs/module/os/freebsd/spl
+.PATH: ${SYSDIR}/contrib/openzfs/module/zstd/lib
+
+SRCS+= zstd.c zstd_shim.c
+
CFLAGS+= -I${LDRSRC}
CFLAGS+= -I${SYSDIR}/cddl/boot/zfs
-CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${SYSDIR}/crypto/skein
+ZFS_CFLAGS= -D_KERNEL -D__KERNEL__ -DIN_BASE -D_SYS_VMEM_H_ \
+ -DZFS_CONTEXT_OS_H_ -DKLD_MODULE \
+ -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/ \
+ -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl \
+ -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs \
+ -I${SRCTOP}/sys/contrib/openzfs/include \
+ -I${SRCTOP}/sys/contrib/ck/include \
-# Do not unroll skein loops, reduce code size
CFLAGS.skein_block.c+= -DSKEIN_LOOP=111
-CFLAGS.zfs.c+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
+CFLAGS.zfs.c+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl
+CFLAGS.nvlist.c+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl
+CFLAGS.list.c= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h ${ZFS_CFLAGS}
+CFLAGS.zstd_shim.c+= ${ZFS_CFLAGS} -D_SYS_RWLOCK_H_ -D_SYS_MALLOC_H_ -D_OPENSOLARIS_SYS_KMEM_H_ -D_SPL_KMEM_CACHE_H -D_SYS_SPA_H -Wno-include-next-absolute-path -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/types.h -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/param.h -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/proc.h -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/mutex.h -I${SYSDIR}/contrib/openzfs/module/zstd
CFLAGS+= -Wformat -Wall
Index: stand/libsa/zfs/zfsimpl.c
===================================================================
--- stand/libsa/zfs/zfsimpl.c
+++ stand/libsa/zfs/zfsimpl.c
@@ -40,6 +40,7 @@
#include "zfsimpl.h"
#include "zfssubr.c"
+extern int zstd_init(void);
struct zfsmount {
const spa_t *spa;
@@ -168,6 +169,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,74 @@
+typedef int krw_t;
+u_int cpu_feature;
+
+extern void Free(void *p, char *file, int line);
+extern void *Malloc(size_t bytes, char *file, int line);
+#define M_WAITOK 0
+#define M_ZERO 0
+#define M_NOWAIT 0
+#define MALLOC_DECLARE(x)
+#define KM_SLEEP 0
+
+#define zfs_kmem_alloc(size, flags) Malloc((size), __FILE__, __LINE__)
+#define zfs_kmem_free(p, size) Free(p, __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;
+
+#include <zfs_zstd.c>
+
+uintptr_t *__start_set_pcpu;
+
+uintptr_t *__stop_set_pcpu;
+
+void
+__kstat_install(kstat_t *ksp)
+{
+
+}
+
+void
+__kstat_delete(kstat_t *ksp)
+{
+
+}
+
+kstat_t *
+__kstat_create(const char *ks_module, int ks_instance,
+ const char *ks_name, const char *ks_class, uchar_t ks_type,
+ uint_t ks_ndata, uchar_t ks_flags)
+{
+ return (NULL);
+}
+
+void
+_sx_xunlock(struct sx *sx, const char *file, int line)
+{
+
+}
+
+int
+sx_try_xlock_(struct sx *sx, const char *file, int line)
+{
+ return (1);
+}
+
+int
+_sx_xlock(struct sx *sx, int opts, const char *file, int line)
+{
+ return (0);
+}
+
+void
+sx_init_flags(struct sx *sx, const char *description, int opts)
+{
+
+}
+
+void
+sx_destroy(struct sx *sx)
+{
+
+}
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_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STD_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
@@ -107,6 +107,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 +185,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/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/taskq.h
===================================================================
--- sys/contrib/openzfs/include/os/freebsd/spl/sys/taskq.h
+++ sys/contrib/openzfs/include/os/freebsd/spl/sys/taskq.h
@@ -30,6 +30,7 @@
#include <sys/proc.h>
#include <sys/taskqueue.h>
#include <sys/thread.h>
+#include <sys/rwlock.h>
#include <sys/ck.h>
#ifdef __cplusplus
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,11 @@
* Generic doubly-linked list implementation
*/
+#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))

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 2, 6:26 AM (21 h, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30711727
Default Alt Text
D26207.id76296.diff (14 KB)

Event Timeline