dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 8fbb01adb33b5d1332f5962f092d1a513e7641c2
parent 91baa036ca3e412aca7fa92d30f7ccf3c1546cd2
Author: sin <sin@2f30.org>
Date:   Mon, 18 Feb 2019 17:00:26 +0000

Update stats

Diffstat:
Mdedup.c | 29+++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -31,8 +31,9 @@ enum { }; struct stats { - uint64_t total_bytes; - uint64_t actual_bytes; + uint64_t orig_size; + uint64_t comp_size; + uint64_t dedup_size; uint64_t cache_hits; uint64_t cache_misses; }; @@ -426,7 +427,7 @@ dedup(int fd, char *msg) if (n > 0) { bufsize += n; - enthdr.st.total_bytes += n; + enthdr.st.orig_size += n; } blksize = chunk_blk(inp, bufsize); @@ -436,6 +437,8 @@ dedup(int fd, char *msg) bdescr.offset = enthdr.store_size; bdescr.size = csize; + enthdr.st.comp_size += bdescr.size; + hash_blk(outp, bdescr.size, bdescr.md); /* Calculate file hash one block at a time */ @@ -458,7 +461,7 @@ dedup(int fd, char *msg) add_cent(cent); cache_dirty = 1; - enthdr.st.actual_bytes += bdescr.size; + enthdr.st.dedup_size += bdescr.size; enthdr.st.cache_misses++; } else { ent->bdescr[ent->nblks++] = bdescr; @@ -676,18 +679,12 @@ init(void) if (sb.st_size != 0) xread(ifd, &enthdr, sizeof(enthdr)); if (verbose) { - float ratio; - - fprintf(stderr, "total bytes: %llu bytes\n", - (unsigned long long)enthdr.st.total_bytes); - fprintf(stderr, "actual bytes: %llu bytes\n", - (unsigned long long)enthdr.st.actual_bytes); - - if (enthdr.st.total_bytes) { - ratio = enthdr.st.actual_bytes * 100; - ratio /= enthdr.st.total_bytes; - fprintf(stderr, "dedup ratio: %f\n", ratio); - } + fprintf(stderr, "original size: %llu bytes\n", + (unsigned long long)enthdr.st.orig_size); + fprintf(stderr, "compressed size: %llu bytes\n", + (unsigned long long)enthdr.st.comp_size); + fprintf(stderr, "deduplicated size: %llu bytes\n", + (unsigned long long)enthdr.st.dedup_size); fprintf(stderr, "cache hits: %llu\n", (unsigned long long)enthdr.st.cache_hits);