42#define ZSTD_STATIC_LINKING_ONLY
46#define LZO_PAGE_SIZE 4096
59#define LZO1X_MEM_COMPRESS ((uint32_t) (16384L * sizeof(uint8_t*)))
61#define M1_MAX_OFFSET 0x0400
62#define M2_MAX_OFFSET 0x0800
63#define M3_MAX_OFFSET 0x4000
64#define M4_MAX_OFFSET 0xbfff
66#define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
73#define _DV2(p, shift1, shift2) (((( (uint32_t)(p[2]) << shift1) ^ p[1]) << shift2) ^ p[0])
74#define DVAL_NEXT(dv, p) dv ^= p[-1]; dv = (((dv) >> 5) ^ ((uint32_t)(p[2]) << (2*5)))
75#define _DV(p, shift) _DV2(p, shift, shift)
76#define DVAL_FIRST(dv, p) dv = _DV((p), 5)
77#define _DINDEX(dv, p) ((40799u * (dv)) >> 5)
78#define DINDEX(dv, p) (((_DINDEX(dv, p)) & 0x3fff) << 0)
79#define UPDATE_D(dict, cycle, dv, p) dict[DINDEX(dv, p)] = (p)
80#define UPDATE_I(dict, cycle, index, p) dict[index] = (p)
82#define LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, max_offset) \
83 ((void*) m_pos < (void*) in || \
84 (m_off = (uint8_t*) ip - (uint8_t*) m_pos) <= 0 || \
87#define LZO_BYTE(x) ((unsigned char) (x))
89#define ZSTD_ALLOC_TAG 0x6474737a
92#define ZSTD_BTRFS_MAX_WINDOWLOG 17
122 if (
stream->error)
return 0;
153 if (
stream->outpos < back) {
173 bool backcopy =
false;
197 len = (
byte >> 5) - 1;
200 }
else if (
byte >> 5) {
213 back = (1 << 14) + ((
byte & 8) << 11);
221 if (back == (1 << 14)) {
227 }
else if (backcopy) {
269 backcopy = !backcopy;
289 if (partlen + inoff > inlen) {
290 ERR(
"overflow: %x + %x > %x\n", partlen, inoff, inlen);
299 stream.out = &outbuf[outoff];
305 ERR(
"do_lzo_decompress returned %08lx\n",
Status);
319 }
while (inoff < inlen && outlen > 0);
347 ERR(
"deflateInit returned %i\n",
ret);
361 ERR(
"deflate returned %i\n",
ret);
388 ERR(
"inflateInit returned %i\n",
ret);
402 ERR(
"inflate returned %i\n",
ret);
414 ERR(
"inflateEnd returned %i\n",
ret);
428 const uint8_t* ip_end =
in + in_len - 9 - 4;
448 m_pos = dict[dindex];
462 *
op++ = *ii++; *
op++ = *ii++; *
op++ = *ii++;
517 if (*m_pos++ != *
ip++ || *m_pos++ != *
ip++ || *m_pos++ != *
ip++ ||
518 *m_pos++ != *
ip++ || *m_pos++ != *
ip++ || *m_pos++ != *
ip++) {
522 if (m_len < 3 || m_len > 8)
527 *
op++ =
LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
536 if (m_off <= 0 || m_off > 0x7fff)
545 while (
ip <
end && *m_pos == *
ip)
564 if (m_off <= 0 || m_off > 0x7fff)
573 while (m_len > 255) {
597 if (in_end - ii > 0) {
600 if (
op ==
out &&
t <= 238)
637 else if (
stream->inlen <= 9 + 4) {
661 return inlen + (inlen / 16) + 64 + 3;
679 size_t init_res,
read;
686 ERR(
"ZSTD_createDStream failed.\n");
703 output.
size = outlen;
729 unsigned int num_pages;
730 unsigned int comp_data_len;
747 ERR(
"out of memory\n");
753 ERR(
"out of memory\n");
764 for (
unsigned int i = 0;
i < num_pages;
i++) {
771 ERR(
"lzo1x_1_compress returned %08lx\n",
Status);
807 size_t init_res, written;
815 ERR(
"ZSTD_createCStream failed.\n");
837 output.
size = outlen;
862 *space_left = output.
size - output.
pos;
881 unsigned int buflen = 0;
905 ERR(
"excise_extents returned %08lx\n",
Status);
911 ERR(
"out of memory\n");
915 for (
i = 0;
i < num_parts;
i++) {
916 if (
i == num_parts - 1)
924 ERR(
"add_calc_job_comp returned %08lx\n",
Status);
926 for (
unsigned int j = 0;
j <
i;
j++) {
938 for (
int i = num_parts - 1;
i >= 0;
i--) {
948 ERR(
"calc job returned %08lx\n",
Status);
950 for (
unsigned int i = 0;
i < num_parts;
i++) {
958 for (
unsigned int i = 0;
i < num_parts;
i++) {
959 if (
parts[
i].
cj->space_left >=
fcb->
Vcb->superblock.sector_size) {
968 if ((
parts[
i].outlen & (
fcb->
Vcb->superblock.sector_size - 1)) != 0) {
980 buflen +=
parts[
i].outlen;
998 ERR(
"out of memory\n");
1006 for (
i = 0;
i < num_parts;
i++) {
1020 le =
fcb->
Vcb->chunks.Flink;
1021 while (le != &
fcb->
Vcb->chunks) {
1055 ERR(
"alloc_chunk returned %08lx\n",
Status);
1073 WARN(
"couldn't find any data chunks with %x bytes free\n", buflen);
1086 ERR(
"write_data_complete returned %08lx\n",
Status);
1097 unsigned int sl = buflen >>
fcb->
Vcb->sector_shift;
1101 ERR(
"out of memory\n");
1116 for (
i = 0;
i < num_parts;
i++) {
1123 ERR(
"out of memory\n");
1148 ERR(
"out of memory\n");
1163 ERR(
"add_extent_to_fcb returned %08lx\n",
Status);
1177 extaddr +=
parts[
i].outlen;
1189 for (
i = 0;
i < num_parts;
i++) {
1193 extaddr +=
parts[
i].outlen;
std::map< E_STRING, PART_TEST > parts
#define acquire_chunk_lock(c, Vcb)
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
void do_calc_job(device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
NTSTATUS alloc_chunk(device_extension *Vcb, uint64_t flags, chunk **pc, bool full_size) __attribute__((nonnull(1
NTSTATUS NTSTATUS NTSTATUS NTSTATUS NTSTATUS excise_extents(device_extension *Vcb, fcb *fcb, uint64_t start_data, uint64_t end_data, PIRP Irp, LIST_ENTRY *rollback) __attribute__((nonnull(1
NTSTATUS bool find_data_address_in_chunk(device_extension *Vcb, chunk *c, uint64_t length, uint64_t *address) __attribute__((nonnull(1
NTSTATUS add_calc_job_comp(device_extension *Vcb, uint8_t compression, void *in, unsigned int inlen, void *out, unsigned int outlen, calc_job **pcj)
_In_ fcb _In_ chunk _In_ uint64_t start_data
#define COMPRESSED_EXTENT_SIZE
void add_changed_extent_ref(chunk *c, uint64_t address, uint64_t size, uint64_t root, uint64_t objid, uint64_t offset, uint32_t count, bool no_csum)
NTSTATUS bool void NTSTATUS add_extent_to_fcb(_In_ fcb *fcb, _In_ uint64_t offset, _In_reads_bytes_(edsize) EXTENT_DATA *ed, _In_ uint16_t edsize, _In_ bool unique, _In_opt_ _When_(return >=0, __drv_aliasesMem) void *csum, _In_ LIST_ENTRY *rollback) __attribute__((nonnull(1
NTSTATUS NTSTATUS NTSTATUS write_data_complete(device_extension *Vcb, uint64_t address, void *data, uint32_t length, PIRP Irp, chunk *c, bool file_write, uint64_t irp_offset, ULONG priority) __attribute__((nonnull(1
void calc_thread_main(device_extension *Vcb, calc_job *cj)
#define release_chunk_lock(c, Vcb)
void space_list_subtract(chunk *c, uint64_t address, uint64_t length, LIST_ENTRY *rollback)
#define NT_SUCCESS(StatCode)
int inflate(z_streamp strm, int flush)
int inflateEnd(z_streamp strm)
int deflate(z_streamp strm, int flush) DECLSPEC_HIDDEN
int deflateEnd(z_streamp strm) DECLSPEC_HIDDEN
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
void mark_fcb_dirty(_In_ fcb *fcb)
#define BTRFS_COMPRESSION_LZO
#define BTRFS_INCOMPAT_FLAGS_COMPRESS_ZSTD
#define BTRFS_COMPRESSION_ZLIB
#define BTRFS_COMPRESSION_ZSTD
#define BTRFS_ENCODING_NONE
#define EXTENT_TYPE_REGULAR
#define BTRFS_COMPRESSION_NONE
#define BTRFS_ENCRYPTION_NONE
#define BTRFS_INCOMPAT_FLAGS_COMPRESS_LZO
static int lzo_len(lzo_stream *stream, int byte, int mask)
NTSTATUS zlib_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int level, unsigned int *space_left)
static __inline uint32_t lzo_max_outlen(uint32_t inlen)
static void zstd_free(void *opaque, void *address)
NTSTATUS zlib_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
static void lzo_copyback(lzo_stream *stream, uint32_t back, int len)
#define UPDATE_I(dict, cycle, index, p)
NTSTATUS zstd_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
#define LZO1X_MEM_COMPRESS
#define DVAL_FIRST(dv, p)
#define ZSTD_BTRFS_MAX_WINDOWLOG
static void zlib_free(void *opaque, void *ptr)
static NTSTATUS lzo_do_compress(const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t *out_len, void *wrkmem)
static void lzo_copy(lzo_stream *stream, int len)
NTSTATUS lzo_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t inpageoff)
#define LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, max_offset)
static uint8_t lzo_nextbyte(lzo_stream *stream)
static void * zlib_alloc(void *opaque, unsigned int items, unsigned int size)
NTSTATUS write_compressed(fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, LIST_ENTRY *rollback)
static NTSTATUS do_lzo_decompress(lzo_stream *stream)
#define UPDATE_D(dict, cycle, dv, p)
NTSTATUS lzo_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int *space_left)
static void * zstd_malloc(void *opaque, size_t size)
static NTSTATUS lzo1x_1_compress(lzo_stream *stream)
NTSTATUS zstd_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t level, unsigned int *space_left)
__kernel_ptrdiff_t ptrdiff_t
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define ExAcquireResourceExclusiveLite(res, wait)
#define ExAcquireResourceSharedLite(res, wait)
#define FSRTL_FLAG2_IS_PAGING_FILE
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum const GLfloat * params
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
#define STATUS_INTERNAL_ERROR
#define BTRFS_INODE_NOCOMPRESS
#define BTRFS_INODE_NODATASUM
#define offsetof(TYPE, MEMBER)
#define inflateInit(strm)
#define deflateInit(strm, level)
struct _LIST_ENTRY * Flink
struct _device_extension * Vcb
enum prop_compression_type prop_compression
FSRTL_ADVANCED_FCB_HEADER Header
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INSUFFICIENT_RESOURCES
ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream *zds)
ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream *zcs)
ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
ZSTDLIB_API const char * ZSTD_getErrorName(size_t code)
ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream *zds)
ZSTD_CStream * ZSTD_createCStream_advanced(ZSTD_customMem customMem)
ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
size_t ZSTD_initCStream_advanced(ZSTD_CStream *zcs, const void *dict, size_t dictSize, ZSTD_parameters params, unsigned long long pss)
ZSTD_DStream * ZSTD_createDStream_advanced(ZSTD_customMem customMem)