Fix calculation of extra scratch space for Dedupe.

Add missing return value check in small buffer Delta2.
Update test failure detection in test driver.
This commit is contained in:
Moinak Ghosh 2013-01-03 22:25:14 +05:30
parent d9eb82e0e8
commit 47ebd5b752
3 changed files with 12 additions and 10 deletions

View file

@ -127,6 +127,8 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
*((uint64_t *)dst) = LE64(srclen);
dst += MAIN_HDR;
rv = delta2_encode_real(src, srclen, dst, dstlen, rle_thresh, 1, &hdr_ovr);
if (rv == -1)
return (rv);
*dstlen += MAIN_HDR;
DEBUG_STAT_EN(fprintf(stderr, "DELTA2: srclen: %" PRIu64 ", dstlen: %" PRIu64 "\n", srclen, *dstlen));
DEBUG_STAT_EN(fprintf(stderr, "DELTA2: header overhead: %d\n", hdr_ovr));
@ -288,7 +290,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
/*
* No need to check for destination buffer overflow since
* dstlen == srclen always.
* dstlen >= srclen always.
*/
if ( gtot1 > (srclen - (DELTA_HDR + LIT_HDR + MAIN_HDR)) ) {
if (srclen == DELTA2_CHUNK) {

9
main.c
View file

@ -264,7 +264,6 @@ preproc_compress(compress_func_ptr cmp_func, void *src, uint64_t srclen, void *d
if (type > 0)
result = 0;
}
return (result);
}
@ -1489,8 +1488,12 @@ start_compress(const char *filename, uint64_t chunksize, int level)
else
flags |= FLAG_DEDUP_FIXED;
/* Additional scratch space for dedup arrays. */
compressed_chunksize += (dedupe_buf_extra(chunksize, 0, algo,
enable_delta_encode) - (compressed_chunksize - chunksize));
if (chunksize + dedupe_buf_extra(chunksize, 0, algo, enable_delta_encode)
> compressed_chunksize) {
compressed_chunksize += (chunksize +
dedupe_buf_extra(chunksize, 0, algo, enable_delta_encode)) -
compressed_chunksize;
}
}
if (encrypt_type) {

View file

@ -52,12 +52,9 @@ then
[ $? -ne 0 ] && continue
cd datafiles
(. ../${tf})
if [ $? -ne 0 ]
then
echo "FATAL: Test ${tf} failed"
failures=$((failures + 1))
fi
(. ../${tf}) 2>&1 | tee ${tf}.log
fails=`egrep "^FATAL:" ${tf}.log | wc -l`
failures=$((failures + fails))
cd $PDIR
done
else