Fix handling of compression flags in adaptive mode
Fix error handling when chunk size is too small for dedupe Bump version to 0.6
This commit is contained in:
parent
6b6e564886
commit
bde917c8e9
4 changed files with 26 additions and 13 deletions
|
@ -197,17 +197,17 @@ adapt_decompress(void *src, size_t srclen, void *dst,
|
||||||
size_t *dstlen, int level, uchar_t chdr, void *data)
|
size_t *dstlen, int level, uchar_t chdr, void *data)
|
||||||
{
|
{
|
||||||
struct adapt_data *adat = (struct adapt_data *)(data);
|
struct adapt_data *adat = (struct adapt_data *)(data);
|
||||||
uchar_t HDR;
|
uchar_t cmp_flags;
|
||||||
|
|
||||||
HDR = chdr;
|
cmp_flags = (chdr>>4) & CHDR_ALGO_MASK;
|
||||||
|
|
||||||
if (HDR & (COMPRESS_LZMA << 4)) {
|
if (cmp_flags == COMPRESS_LZMA) {
|
||||||
return (lzma_decompress(src, srclen, dst, dstlen, level, chdr, adat->lzma_data));
|
return (lzma_decompress(src, srclen, dst, dstlen, level, chdr, adat->lzma_data));
|
||||||
|
|
||||||
} else if (HDR & (COMPRESS_BZIP2 << 4)) {
|
} else if (cmp_flags == COMPRESS_BZIP2) {
|
||||||
return (bzip2_decompress(src, srclen, dst, dstlen, level, chdr, NULL));
|
return (bzip2_decompress(src, srclen, dst, dstlen, level, chdr, NULL));
|
||||||
|
|
||||||
} else if (HDR & (COMPRESS_PPMD << 4)) {
|
} else if (cmp_flags == COMPRESS_PPMD) {
|
||||||
return (ppmd_decompress(src, srclen, dst, dstlen, level, chdr, adat->ppmd_data));
|
return (ppmd_decompress(src, srclen, dst, dstlen, level, chdr, adat->ppmd_data));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
16
main.c
16
main.c
|
@ -467,11 +467,15 @@ start_decompress(const char *filename, const char *to_filename)
|
||||||
UNCOMP_BAIL;
|
UNCOMP_BAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (enable_rabin_scan)
|
if (enable_rabin_scan) {
|
||||||
tdat->rctx = create_rabin_context(chunksize, compressed_chunksize,
|
tdat->rctx = create_rabin_context(chunksize, compressed_chunksize,
|
||||||
algo, enable_delta_encode);
|
algo, enable_delta_encode);
|
||||||
else
|
if (tdat->rctx == NULL) {
|
||||||
|
UNCOMP_BAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
tdat->rctx = NULL;
|
tdat->rctx = NULL;
|
||||||
|
}
|
||||||
if (pthread_create(&(tdat->thr), NULL, perform_decompress,
|
if (pthread_create(&(tdat->thr), NULL, perform_decompress,
|
||||||
(void *)tdat) != 0) {
|
(void *)tdat) != 0) {
|
||||||
perror("Error in thread creation: ");
|
perror("Error in thread creation: ");
|
||||||
|
@ -981,11 +985,15 @@ start_compress(const char *filename, uint64_t chunksize, int level)
|
||||||
COMP_BAIL;
|
COMP_BAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (enable_rabin_scan)
|
if (enable_rabin_scan) {
|
||||||
tdat->rctx = create_rabin_context(chunksize, compressed_chunksize,
|
tdat->rctx = create_rabin_context(chunksize, compressed_chunksize,
|
||||||
algo, enable_delta_encode);
|
algo, enable_delta_encode);
|
||||||
else
|
if (tdat->rctx == NULL) {
|
||||||
|
COMP_BAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
tdat->rctx = NULL;
|
tdat->rctx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pthread_create(&(tdat->thr), NULL, perform_compress,
|
if (pthread_create(&(tdat->thr), NULL, perform_compress,
|
||||||
(void *)tdat) != 0) {
|
(void *)tdat) != 0) {
|
||||||
|
|
11
pcompress.h
11
pcompress.h
|
@ -39,18 +39,23 @@ extern "C" {
|
||||||
#define MIN_CHUNK 2048
|
#define MIN_CHUNK 2048
|
||||||
#define VERSION 2
|
#define VERSION 2
|
||||||
#define FLAG_DEDUP 1
|
#define FLAG_DEDUP 1
|
||||||
#define UTILITY_VERSION 0.5
|
#define UTILITY_VERSION 0.6
|
||||||
|
|
||||||
#define COMPRESSED 1
|
#define COMPRESSED 1
|
||||||
#define UNCOMPRESSED 0
|
#define UNCOMPRESSED 0
|
||||||
#define CHSIZE_MASK 0x80
|
#define CHSIZE_MASK 0x80
|
||||||
#define BZIP2_A_NUM 16
|
#define BZIP2_A_NUM 16
|
||||||
#define LZMA_A_NUM 32
|
#define LZMA_A_NUM 32
|
||||||
|
#define CHUNK_FLAG_DEDUP 2
|
||||||
|
#define COMP_EXTN ".pz"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lower 3 bits in higher nibble indicate compression algorithm.
|
||||||
|
*/
|
||||||
#define COMPRESS_LZMA 1
|
#define COMPRESS_LZMA 1
|
||||||
#define COMPRESS_BZIP2 2
|
#define COMPRESS_BZIP2 2
|
||||||
#define COMPRESS_PPMD 3
|
#define COMPRESS_PPMD 3
|
||||||
#define CHUNK_FLAG_DEDUP 2
|
#define CHDR_ALGO_MASK 7
|
||||||
#define COMP_EXTN ".pz"
|
|
||||||
|
|
||||||
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
|
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
|
||||||
extern uint64_t lzma_crc64_8bchk(const uint8_t *buf, size_t size,
|
extern uint64_t lzma_crc64_8bchk(const uint8_t *buf, size_t size,
|
||||||
|
|
|
@ -105,7 +105,7 @@ create_rabin_context(uint64_t chunksize, uint64_t real_chunksize, const char *al
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunksize < RAB_MIN_CHUNK_SIZE) {
|
if (chunksize < RAB_MIN_CHUNK_SIZE) {
|
||||||
fprintf(stderr, "Minimum chunk size for Dedup must be %l bytes\n",
|
fprintf(stderr, "Minimum chunk size for Dedup must be %llu bytes\n",
|
||||||
RAB_MIN_CHUNK_SIZE);
|
RAB_MIN_CHUNK_SIZE);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue