4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
28 * Copyright (c) 2015, 2016 by Delphix. All rights reserved.
31 #ifndef _SYS_ZIO_COMPRESS_H
32 #define _SYS_ZIO_COMPRESS_H
41 ZIO_COMPRESS_INHERIT = 0,
57 ZIO_COMPRESS_FUNCTIONS
60 /* Common signature for all zio compress functions. */
61 typedef size_t zio_compress_func_t(void *src, void *dst,
62 size_t s_len, size_t d_len, int);
63 /* Common signature for all zio decompress functions. */
64 typedef int zio_decompress_func_t(void *src, void *dst,
65 size_t s_len, size_t d_len, int);
67 * Common signature for all zio decompress functions using an ABD as input.
68 * This is helpful if you have both compressed ARC and scatter ABDs enabled,
69 * but is not a requirement for all compression algorithms.
71 typedef int zio_decompress_abd_func_t(abd_t *src, void *dst,
72 size_t s_len, size_t d_len, int);
75 * Information about each compression function.
77 typedef struct zio_compress_info {
80 zio_compress_func_t *ci_compress;
81 zio_decompress_func_t *ci_decompress;
82 } zio_compress_info_t;
84 extern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS];
87 * Compression routines.
89 extern size_t lzjb_compress(void *src, void *dst, size_t s_len, size_t d_len,
91 extern int lzjb_decompress(void *src, void *dst, size_t s_len, size_t d_len,
93 extern size_t gzip_compress(void *src, void *dst, size_t s_len, size_t d_len,
95 extern int gzip_decompress(void *src, void *dst, size_t s_len, size_t d_len,
97 extern size_t zle_compress(void *src, void *dst, size_t s_len, size_t d_len,
99 extern int zle_decompress(void *src, void *dst, size_t s_len, size_t d_len,
101 extern void lz4_init(void);
102 extern void lz4_fini(void);
103 extern size_t lz4_compress(void *src, void *dst, size_t s_len, size_t d_len,
105 extern int lz4_decompress(void *src, void *dst, size_t s_len, size_t d_len,
109 * Compress and decompress data if necessary.
111 extern size_t zio_compress_data(enum zio_compress c, abd_t *src, void *dst,
113 extern int zio_decompress_data(enum zio_compress c, abd_t *src, void *dst,
114 size_t s_len, size_t d_len);
115 extern int zio_decompress_data_buf(enum zio_compress c, void *src, void *dst,
116 size_t s_len, size_t d_len);
119 * Module lifetime management.
121 extern void zio_compress_init(void);
122 extern void zio_compress_fini(void);
128 #endif /* _SYS_ZIO_COMPRESS_H */