From be1d0857a60f7ae01aeaaf54b74866562b86d208 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 28 Aug 2013 09:46:10 +0530 Subject: [PATCH] Avoid calling compression routine when dedupe reduces data size to zero. --- pcompress.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcompress.c b/pcompress.c index 9eec894..10ed1d9 100644 --- a/pcompress.c +++ b/pcompress.c @@ -1478,11 +1478,12 @@ plain_index: o_chunksize = _chunksize; /* Compress data chunk. */ - if (pctx->lzp_preprocess || pctx->enable_delta2_encode) { + if ((pctx->lzp_preprocess || pctx->enable_delta2_encode) && _chunksize > 0) { rv = preproc_compress(pctx, tdat->compress, tdat->uncompressed_chunk + dedupe_index_sz, _chunksize, compressed_chunk + index_size_cmp, &_chunksize, tdat->level, 0, tdat->data, tdat->props); - } else { + + } else if (_chunksize > 0) { DEBUG_STAT_EN(double strt, en); DEBUG_STAT_EN(strt = get_wtime_millis()); @@ -1491,6 +1492,8 @@ plain_index: DEBUG_STAT_EN(en = get_wtime_millis()); DEBUG_STAT_EN(fprintf(stderr, "Chunk compression speed %.3f MB/s\n", get_mb_s(_chunksize, strt, en))); + } else { + rv = -1; } /* Can't compress data just retain as-is. */