Capability to list offset and length of each block when deduplication for external use.

This commit is contained in:
Moinak Ghosh 2014-03-30 17:35:21 +05:30
parent 2f11e11717
commit 935717373b
5 changed files with 17 additions and 1 deletions

View file

@ -361,6 +361,9 @@ Advanced usage
-M Display memory allocator statistics.
-C Display compression statistics.
-CC Display compression statistics and print the offset and length of each
variable length dedupe block if variable block deduplication is being
used. This has no effect for fixed block deduplication.
Environment Variables
=====================

View file

@ -2243,6 +2243,7 @@ start_compress(pc_ctx_t *pctx, const char *filename, uint64_t chunksize, int lev
COMP_BAIL;
}
tdat->rctx->show_chunks = pctx->show_chunks;
tdat->rctx->index_sem = &(tdat->index_sem);
tdat->rctx->id = i;
}
@ -2906,7 +2907,10 @@ init_pc_context(pc_ctx_t *pctx, int argc, char *argv[])
break;
case 'C':
pctx->hide_cmp_stats = 0;
if (pctx->hide_cmp_stats)
pctx->hide_cmp_stats = 0;
else
pctx->show_chunks = 1;
break;
case 'D':

View file

@ -198,6 +198,7 @@ typedef struct pc_ctx {
int nthreads;
int hide_mem_stats;
int hide_cmp_stats;
int show_chunks;
int enable_rabin_scan;
int enable_rabin_global;
int enable_delta_encode;

View file

@ -293,6 +293,7 @@ create_dedupe_context(uint64_t chunksize, uint64_t real_chunksize, int rab_blk_s
ctx->deltac_min_distance = props->deltac_min_distance;
ctx->pagesize = sysconf(_SC_PAGE_SIZE);
ctx->similarity_cksums = NULL;
ctx->show_chunks = 0;
if (arc) {
arc->pagesize = ctx->pagesize;
if (rab_blk_sz < 3)
@ -679,6 +680,9 @@ dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size, uint64_t of
ctx->g_blocks[blknum].offset = last_offset;
}
DEBUG_STAT_EN(if (length >= ctx->rabin_poly_max_block_size) ++max_count);
if (ctx->show_chunks) {
fprintf(stderr, "Block offset: %" PRIu64 ", length: %u\n", last_offset, length);
}
/*
* Reset the heap structure and find the K min values if Delta Compression
@ -726,6 +730,9 @@ dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size, uint64_t of
ctx->g_blocks[blknum].length = length;
ctx->g_blocks[blknum].offset = last_offset;
}
if (ctx->show_chunks) {
fprintf(stderr, "Block offset: %" PRIu64 ", length: %u\n", last_offset, length);
}
if (ctx->delta_flag) {
uint64_t cur_sketch;

View file

@ -188,6 +188,7 @@ typedef struct {
uint32_t pagesize;
int out_fd;
int id;
int show_chunks; // Debug display of chunks (offset, length)
} dedupe_context_t;
extern dedupe_context_t *create_dedupe_context(uint64_t chunksize, uint64_t real_chunksize,