2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2010-05-28 20:45:14 +00:00
|
|
|
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
2008-11-20 20:01:55 +00:00
|
|
|
* Use is subject to license terms.
|
2016-07-22 15:52:49 +00:00
|
|
|
* Copyright (c) 2015, 2016 by Delphix. All rights reserved.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_ZIO_COMPRESS_H
|
|
|
|
#define _SYS_ZIO_COMPRESS_H
|
|
|
|
|
2016-07-22 15:52:49 +00:00
|
|
|
#include <sys/abd.h>
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-07-11 17:45:52 +00:00
|
|
|
enum zio_compress {
|
|
|
|
ZIO_COMPRESS_INHERIT = 0,
|
|
|
|
ZIO_COMPRESS_ON,
|
|
|
|
ZIO_COMPRESS_OFF,
|
|
|
|
ZIO_COMPRESS_LZJB,
|
|
|
|
ZIO_COMPRESS_EMPTY,
|
|
|
|
ZIO_COMPRESS_GZIP_1,
|
|
|
|
ZIO_COMPRESS_GZIP_2,
|
|
|
|
ZIO_COMPRESS_GZIP_3,
|
|
|
|
ZIO_COMPRESS_GZIP_4,
|
|
|
|
ZIO_COMPRESS_GZIP_5,
|
|
|
|
ZIO_COMPRESS_GZIP_6,
|
|
|
|
ZIO_COMPRESS_GZIP_7,
|
|
|
|
ZIO_COMPRESS_GZIP_8,
|
|
|
|
ZIO_COMPRESS_GZIP_9,
|
|
|
|
ZIO_COMPRESS_ZLE,
|
|
|
|
ZIO_COMPRESS_LZ4,
|
|
|
|
ZIO_COMPRESS_FUNCTIONS
|
|
|
|
};
|
|
|
|
|
2013-06-11 17:12:34 +00:00
|
|
|
/* Common signature for all zio compress functions. */
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef size_t zio_compress_func_t(void *src, void *dst,
|
|
|
|
size_t s_len, size_t d_len, int);
|
2013-06-11 17:12:34 +00:00
|
|
|
/* Common signature for all zio decompress functions. */
|
2008-11-20 20:01:55 +00:00
|
|
|
typedef int zio_decompress_func_t(void *src, void *dst,
|
|
|
|
size_t s_len, size_t d_len, int);
|
|
|
|
|
2016-07-22 15:52:49 +00:00
|
|
|
/*
|
|
|
|
* 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,
|
|
|
|
* but is not a requirement for all compression algorithms.
|
|
|
|
*/
|
|
|
|
typedef int zio_decompress_abd_func_t(abd_t *src, void *dst,
|
|
|
|
size_t s_len, size_t d_len, int);
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Information about each compression function.
|
|
|
|
*/
|
2013-02-15 04:37:43 +00:00
|
|
|
typedef const struct zio_compress_info {
|
2016-07-22 15:52:49 +00:00
|
|
|
char *ci_name;
|
|
|
|
int ci_level;
|
|
|
|
zio_compress_func_t *ci_compress;
|
|
|
|
zio_decompress_func_t *ci_decompress;
|
2008-11-20 20:01:55 +00:00
|
|
|
} zio_compress_info_t;
|
|
|
|
|
|
|
|
extern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS];
|
|
|
|
|
2013-01-23 09:54:30 +00:00
|
|
|
/*
|
|
|
|
* lz4 compression init & free
|
|
|
|
*/
|
|
|
|
extern void lz4_init(void);
|
|
|
|
extern void lz4_fini(void);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Compression routines.
|
|
|
|
*/
|
|
|
|
extern size_t lzjb_compress(void *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
|
|
|
extern int lzjb_decompress(void *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
|
|
|
extern size_t gzip_compress(void *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
|
|
|
extern int gzip_decompress(void *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
2010-05-28 20:45:14 +00:00
|
|
|
extern size_t zle_compress(void *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
|
|
|
extern int zle_decompress(void *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
2013-10-05 21:55:24 +00:00
|
|
|
extern size_t lz4_compress_zfs(void *src, void *dst, size_t s_len, size_t d_len,
|
2013-01-23 09:54:30 +00:00
|
|
|
int level);
|
2013-10-05 21:55:24 +00:00
|
|
|
extern int lz4_decompress_zfs(void *src, void *dst, size_t s_len, size_t d_len,
|
2013-01-23 09:54:30 +00:00
|
|
|
int level);
|
2016-07-22 15:52:49 +00:00
|
|
|
extern int lz4_decompress_abd(abd_t *src, void *dst, size_t s_len, size_t d_len,
|
|
|
|
int level);
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Compress and decompress data if necessary.
|
|
|
|
*/
|
2016-07-22 15:52:49 +00:00
|
|
|
extern size_t zio_compress_data(enum zio_compress c, abd_t *src, void *dst,
|
2010-05-28 20:45:14 +00:00
|
|
|
size_t s_len);
|
2016-07-22 15:52:49 +00:00
|
|
|
extern int zio_decompress_data(enum zio_compress c, abd_t *src, void *dst,
|
|
|
|
size_t s_len, size_t d_len);
|
|
|
|
extern int zio_decompress_data_buf(enum zio_compress c, void *src, void *dst,
|
2010-05-28 20:45:14 +00:00
|
|
|
size_t s_len, size_t d_len);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SYS_ZIO_COMPRESS_H */
|