FreeBSD ZFS
The Zettabyte File System
Defines | Functions

lzjb.c File Reference

LZJB compression of on-disk data. More...

#include <sys/zfs_context.h>
#include <sys/types.h>
Include dependency graph for lzjb.c:

Go to the source code of this file.

Defines

#define MATCH_BITS   6
#define MATCH_MIN   3
#define MATCH_MAX   ((1 << MATCH_BITS) + (MATCH_MIN - 1))
#define OFFSET_MASK   ((1 << (16 - MATCH_BITS)) - 1)
#define LEMPEL_SIZE   1024

Functions

size_t lzjb_compress (void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
int lzjb_decompress (void *s_start, void *d_start, size_t s_len, size_t d_len, int n)

Detailed Description

LZJB compression of on-disk data.

We keep our own copy of this algorithm for 3 main reasons: 1. If we didn't, anyone modifying common/os/compress.c would directly break our on disk format 2. Our version of lzjb does not have a number of checks that the common/os version needs and uses 3. We initialize the lempel to ensure deterministic results, so that identical blocks can always be deduplicated. In particular, we are adding the "feature" that compress() can take a destination buffer size and returns the compressed length, or the source length if compression would overflow the destination buffer.

Definition in file lzjb.c.


Define Documentation

#define LEMPEL_SIZE   1024

Definition at line 49 of file lzjb.c.

#define MATCH_BITS   6

Definition at line 45 of file lzjb.c.

#define MATCH_MAX   ((1 << MATCH_BITS) + (MATCH_MIN - 1))

Definition at line 47 of file lzjb.c.

#define MATCH_MIN   3

Definition at line 46 of file lzjb.c.

#define OFFSET_MASK   ((1 << (16 - MATCH_BITS)) - 1)

Definition at line 48 of file lzjb.c.


Function Documentation

size_t lzjb_compress ( void *  s_start,
void *  d_start,
size_t  s_len,
size_t  d_len,
int  n 
)

Definition at line 53 of file lzjb.c.

int lzjb_decompress ( void *  s_start,
void *  d_start,
size_t  s_len,
size_t  d_len,
int  n 
)

Definition at line 101 of file lzjb.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines