2 * Copyright (c) 2010 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Ilya Dryomov <idryomov@gmail.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <crypto/sha2/sha2.h>
39 #define DEDUP_BUF (64 * 1024)
41 /* Sorted list of block CRCs - light version for dedup-simulate */
42 struct sim_dedup_entry_rb_tree;
43 RB_HEAD(sim_dedup_entry_rb_tree, sim_dedup_entry) sim_dedup_tree =
44 RB_INITIALIZER(&sim_dedup_tree);
45 RB_PROTOTYPE2(sim_dedup_entry_rb_tree, sim_dedup_entry, rb_entry,
46 rb_sim_dedup_entry_compare, hammer_crc_t);
48 struct sim_dedup_entry {
50 u_int64_t ref_blks; /* number of blocks referenced */
51 u_int64_t ref_size; /* size of data referenced */
52 RB_ENTRY(sim_dedup_entry) rb_entry;
55 /* Sorted list of HAMMER B-Tree keys */
56 struct dedup_entry_rb_tree;
57 struct sha_dedup_entry_rb_tree;
59 RB_HEAD(dedup_entry_rb_tree, dedup_entry) dedup_tree =
60 RB_INITIALIZER(&dedup_tree);
61 RB_PROTOTYPE2(dedup_entry_rb_tree, dedup_entry, rb_entry,
62 rb_dedup_entry_compare, hammer_crc_t);
64 RB_PROTOTYPE(sha_dedup_entry_rb_tree, sha_dedup_entry, fict_entry,
65 rb_sha_dedup_entry_compare);
68 struct hammer_btree_leaf_elm leaf;
74 RB_HEAD(sha_dedup_entry_rb_tree, sha_dedup_entry) fict_root;
77 RB_ENTRY(dedup_entry) rb_entry;
80 #define HAMMER_DEDUP_ENTRY_FICTITIOUS 0x0001
82 struct sha_dedup_entry {
83 struct hammer_btree_leaf_elm leaf;
86 u_int8_t sha_hash[SHA256_DIGEST_LENGTH];
87 RB_ENTRY(sha_dedup_entry) fict_entry;
91 * Pass2 list - contains entries that were not dedup'ed because ioctl failed
93 STAILQ_HEAD(, pass2_dedup_entry) pass2_dedup_queue =
94 STAILQ_HEAD_INITIALIZER(pass2_dedup_queue);
96 struct pass2_dedup_entry {
97 struct hammer_btree_leaf_elm leaf;
98 STAILQ_ENTRY(pass2_dedup_entry) sq_entry;
101 #define DEDUP_PASS2 0x0001 /* process_btree_elm() mode */
103 /* PFS global ids - we deal with just one PFS at a run */
105 struct hammer_ioc_pseudofs_rw glob_pfs;
108 * Global accounting variables
110 * Last three don't have to be 64-bit, just to be safe..
112 u_int64_t dedup_alloc_size = 0;
113 u_int64_t dedup_ref_size = 0;
114 u_int64_t dedup_skipped_size = 0;
115 u_int64_t dedup_crc_failures = 0;
116 u_int64_t dedup_sha_failures = 0;
117 u_int64_t dedup_underflows = 0;
119 static int rb_sim_dedup_entry_compare(struct sim_dedup_entry *sim_de1,
120 struct sim_dedup_entry *sim_de2);
121 static int rb_dedup_entry_compare(struct dedup_entry *de1,
122 struct dedup_entry *de2);
123 static int rb_sha_dedup_entry_compare(struct sha_dedup_entry *sha_de1,
124 struct sha_dedup_entry *sha_de2);
125 typedef int (*scan_pfs_cb_t)(hammer_btree_leaf_elm_t scan_leaf, int flags);
126 static void scan_pfs(char *filesystem, scan_pfs_cb_t func);
127 static int collect_btree_elm(hammer_btree_leaf_elm_t scan_leaf, int flags);
128 static int process_btree_elm(hammer_btree_leaf_elm_t scan_leaf, int flags);
129 static int upgrade_chksum(hammer_btree_leaf_elm_t leaf, u_int8_t *sha_hash);
130 static void dump_simulated_dedup(void);
131 static void dump_real_dedup(void);
132 static void dedup_usage(int code);
134 RB_GENERATE2(sim_dedup_entry_rb_tree, sim_dedup_entry, rb_entry,
135 rb_sim_dedup_entry_compare, hammer_crc_t, crc);
136 RB_GENERATE2(dedup_entry_rb_tree, dedup_entry, rb_entry,
137 rb_dedup_entry_compare, hammer_crc_t, leaf.data_crc);
138 RB_GENERATE(sha_dedup_entry_rb_tree, sha_dedup_entry, fict_entry,
139 rb_sha_dedup_entry_compare);
142 rb_sim_dedup_entry_compare(struct sim_dedup_entry *sim_de1,
143 struct sim_dedup_entry *sim_de2)
145 if (sim_de1->crc < sim_de2->crc)
147 if (sim_de1->crc > sim_de2->crc)
154 rb_dedup_entry_compare(struct dedup_entry *de1, struct dedup_entry *de2)
156 if (de1->leaf.data_crc < de2->leaf.data_crc)
158 if (de1->leaf.data_crc > de2->leaf.data_crc)
165 rb_sha_dedup_entry_compare(struct sha_dedup_entry *sha_de1,
166 struct sha_dedup_entry *sha_de2)
168 unsigned long *h1 = (unsigned long *)&sha_de1->sha_hash;
169 unsigned long *h2 = (unsigned long *)&sha_de2->sha_hash;
172 for (i = 0; i < SHA256_DIGEST_LENGTH / (int)sizeof(unsigned long); ++i) {
183 * dedup-simulate <filesystem>
186 hammer_cmd_dedup_simulate(char **av, int ac)
188 struct sim_dedup_entry *sim_de;
193 glob_fd = getpfs(&glob_pfs, av[0]);
195 printf("Dedup-simulate ");
196 scan_pfs(av[0], &collect_btree_elm);
197 printf("Dedup-simulate %s succeeded\n", av[0]);
199 relpfs(glob_fd, &glob_pfs);
202 dump_simulated_dedup();
205 * Calculate simulated dedup ratio and get rid of the tree
207 while ((sim_de = RB_ROOT(&sim_dedup_tree)) != NULL) {
208 assert(sim_de->ref_blks != 0);
209 dedup_ref_size += sim_de->ref_size;
210 dedup_alloc_size += sim_de->ref_size / sim_de->ref_blks;
212 RB_REMOVE(sim_dedup_entry_rb_tree, &sim_dedup_tree, sim_de);
216 printf("Simulated dedup ratio = %.2f\n",
217 (double)dedup_ref_size / dedup_alloc_size);
224 hammer_cmd_dedup(char **av, int ac)
226 struct dedup_entry *de;
227 struct sha_dedup_entry *sha_de;
228 struct pass2_dedup_entry *pass2_de;
237 STAILQ_INIT(&pass2_dedup_queue);
239 glob_fd = getpfs(&glob_pfs, av[0]);
242 scan_pfs(av[0], &process_btree_elm);
244 while ((pass2_de = STAILQ_FIRST(&pass2_dedup_queue)) != NULL) {
245 if (process_btree_elm(&pass2_de->leaf, DEDUP_PASS2))
246 dedup_skipped_size -= pass2_de->leaf.data_len;
248 STAILQ_REMOVE_HEAD(&pass2_dedup_queue, sq_entry);
251 assert(STAILQ_EMPTY(&pass2_dedup_queue));
253 printf("Dedup %s succeeded\n", av[0]);
255 relpfs(glob_fd, &glob_pfs);
261 * Calculate dedup ratio and get rid of the trees
263 while ((de = RB_ROOT(&dedup_tree)) != NULL) {
264 if (de->flags & HAMMER_DEDUP_ENTRY_FICTITIOUS) {
265 while ((sha_de = RB_ROOT(&de->u.fict_root)) != NULL) {
266 assert(sha_de->ref_blks != 0);
267 dedup_ref_size += sha_de->ref_size;
268 dedup_alloc_size += sha_de->ref_size / sha_de->ref_blks;
270 RB_REMOVE(sha_dedup_entry_rb_tree,
271 &de->u.fict_root, sha_de);
274 assert(RB_EMPTY(&de->u.fict_root));
276 assert(de->u.de.ref_blks != 0);
277 dedup_ref_size += de->u.de.ref_size;
278 dedup_alloc_size += de->u.de.ref_size / de->u.de.ref_blks;
281 RB_REMOVE(dedup_entry_rb_tree, &dedup_tree, de);
284 assert(RB_EMPTY(&dedup_tree));
286 assert(dedup_alloc_size != 0);
287 humanize_unsigned(buf, sizeof(buf), dedup_ref_size, "B", 1024);
288 printf("Dedup ratio = %.2f\n"
290 (double)dedup_ref_size / dedup_alloc_size,
293 humanize_unsigned(buf, sizeof(buf), dedup_alloc_size, "B", 1024);
294 printf(" %8s allocated\n", buf);
295 humanize_unsigned(buf, sizeof(buf), dedup_skipped_size, "B", 1024);
296 printf(" %8s skipped\n", buf);
297 printf(" %8jd CRC collisions\n"
298 " %8jd SHA collisions\n"
299 " %8jd bigblock underflows\n",
300 (intmax_t)dedup_crc_failures,
301 (intmax_t)dedup_sha_failures,
302 (intmax_t)dedup_underflows
307 collect_btree_elm(hammer_btree_leaf_elm_t scan_leaf, int flags __unused)
309 struct sim_dedup_entry *sim_de;
311 sim_de = RB_LOOKUP(sim_dedup_entry_rb_tree, &sim_dedup_tree, scan_leaf->data_crc);
313 if (sim_de == NULL) {
314 sim_de = calloc(sizeof(*sim_de), 1);
315 sim_de->crc = scan_leaf->data_crc;
316 RB_INSERT(sim_dedup_entry_rb_tree, &sim_dedup_tree, sim_de);
319 sim_de->ref_blks += 1;
320 sim_de->ref_size += scan_leaf->data_len;
325 validate_dedup_pair(hammer_btree_leaf_elm_t p, hammer_btree_leaf_elm_t q)
327 if ((p->data_offset & HAMMER_OFF_ZONE_MASK) !=
328 (q->data_offset & HAMMER_OFF_ZONE_MASK)) {
331 if (p->data_len != q->data_len) {
338 #define DEDUP_TECH_FAILURE 1
339 #define DEDUP_CMP_FAILURE 2
340 #define DEDUP_INVALID_ZONE 3
341 #define DEDUP_UNDERFLOW 4
342 #define DEDUP_VERS_FAILURE 5
345 deduplicate(hammer_btree_leaf_elm_t p, hammer_btree_leaf_elm_t q)
347 struct hammer_ioc_dedup dedup;
349 bzero(&dedup, sizeof(dedup));
352 * If data_offset fields are the same there is no need to run ioctl,
353 * candidate is already dedup'ed.
355 if (p->data_offset == q->data_offset) {
359 dedup.elm1 = p->base;
360 dedup.elm2 = q->base;
362 if (ioctl(glob_fd, HAMMERIOC_DEDUP, &dedup) < 0) {
363 if (errno == EOPNOTSUPP) {
364 /* must be at least version 5 */
365 return (DEDUP_VERS_FAILURE);
367 /* Technical failure - locking or w/e */
368 return (DEDUP_TECH_FAILURE);
370 if (dedup.head.flags & HAMMER_IOC_DEDUP_CMP_FAILURE) {
371 return (DEDUP_CMP_FAILURE);
373 if (dedup.head.flags & HAMMER_IOC_DEDUP_INVALID_ZONE) {
374 return (DEDUP_INVALID_ZONE);
376 if (dedup.head.flags & HAMMER_IOC_DEDUP_UNDERFLOW) {
377 return (DEDUP_UNDERFLOW);
385 process_btree_elm(hammer_btree_leaf_elm_t scan_leaf, int flags)
387 struct dedup_entry *de;
388 struct sha_dedup_entry *sha_de, temp;
389 struct pass2_dedup_entry *pass2_de;
392 de = RB_LOOKUP(dedup_entry_rb_tree, &dedup_tree, scan_leaf->data_crc);
395 * Insert new entry into CRC tree
397 de = calloc(sizeof(*de), 1);
398 de->leaf = *scan_leaf;
399 RB_INSERT(dedup_entry_rb_tree, &dedup_tree, de);
404 * Found entry in CRC tree
406 if (de->flags & HAMMER_DEDUP_ENTRY_FICTITIOUS) {
408 * Entry in CRC tree is fictitious, so we already had problems
409 * with this CRC. Upgrade (compute SHA) the candidate and
410 * dive into SHA subtree. If upgrade fails insert the candidate
411 * into Pass2 list (it will be processed later).
413 if (upgrade_chksum(scan_leaf, temp.sha_hash))
416 sha_de = RB_FIND(sha_dedup_entry_rb_tree, &de->u.fict_root, &temp);
417 if (sha_de == NULL) {
419 * Nothing in SHA subtree so far, so this is a new
420 * 'dataset'. Insert new entry into SHA subtree.
422 sha_de = calloc(sizeof(*sha_de), 1);
423 sha_de->leaf = *scan_leaf;
424 memcpy(sha_de->sha_hash, temp.sha_hash, SHA256_DIGEST_LENGTH);
425 RB_INSERT(sha_dedup_entry_rb_tree, &de->u.fict_root, sha_de);
426 goto upgrade_stats_sha;
430 * Found entry in SHA subtree, it means we have a potential
431 * dedup pair. Validate it (zones have to match and data_len
432 * field have to be the same too. If validation fails, treat
433 * it as a SHA collision (jump to sha256_failure).
435 if (validate_dedup_pair(&sha_de->leaf, scan_leaf))
439 * We have a valid dedup pair (SHA match, validated).
441 * In case of technical failure (dedup pair was good, but
442 * ioctl failed anyways) insert the candidate into Pass2 list
443 * (we will try to dedup it after we are done with the rest of
446 * If ioctl fails because either of blocks is in the non-dedup
447 * zone (we can dedup only in LARGE_DATA and SMALL_DATA) don't
448 * bother with the candidate and terminate early.
450 * If ioctl fails because of bigblock underflow replace the
451 * leaf node that found dedup entry represents with scan_leaf.
453 error = deduplicate(&sha_de->leaf, scan_leaf);
456 goto upgrade_stats_sha;
457 case DEDUP_TECH_FAILURE:
459 case DEDUP_CMP_FAILURE:
461 case DEDUP_INVALID_ZONE:
462 goto terminate_early;
463 case DEDUP_UNDERFLOW:
465 sha_de->leaf = *scan_leaf;
466 memcpy(sha_de->sha_hash, temp.sha_hash, SHA256_DIGEST_LENGTH);
467 goto upgrade_stats_sha;
468 case DEDUP_VERS_FAILURE:
470 "HAMMER filesystem must be at least "
471 "version 5 to dedup\n");
474 fprintf(stderr, "Unknown error\n");
475 goto terminate_early;
479 * Ooh la la.. SHA-256 collision. Terminate early, there's
480 * nothing we can do here.
483 ++dedup_sha_failures;
484 goto terminate_early;
487 * Candidate CRC is good for now (we found an entry in CRC
488 * tree and it's not fictitious). This means we have a
489 * potential dedup pair.
491 if (validate_dedup_pair(&de->leaf, scan_leaf))
495 * We have a valid dedup pair (CRC match, validated)
497 error = deduplicate(&de->leaf, scan_leaf);
501 case DEDUP_TECH_FAILURE:
503 case DEDUP_CMP_FAILURE:
505 case DEDUP_INVALID_ZONE:
506 goto terminate_early;
507 case DEDUP_UNDERFLOW:
509 de->leaf = *scan_leaf;
511 case DEDUP_VERS_FAILURE:
513 "HAMMER filesystem must be at least "
514 "version 5 to dedup\n");
517 fprintf(stderr, "Unknown error\n");
518 goto terminate_early;
523 * We got a CRC collision - either ioctl failed because of
524 * the comparison failure or validation of the potential
525 * dedup pair went bad. In all cases insert both blocks
526 * into SHA subtree (this requires checksum upgrade) and mark
527 * entry that corresponds to this CRC in the CRC tree
528 * fictitious, so that all futher operations with this CRC go
529 * through SHA subtree.
531 ++dedup_crc_failures;
533 * Insert block that was represented by now fictitious dedup
534 * entry (create a new SHA entry and preserve stats of the
535 * old CRC one). If checksum upgrade fails insert the
536 * candidate into Pass2 list and return - keep both trees
539 sha_de = calloc(sizeof(*sha_de), 1);
540 sha_de->leaf = de->leaf;
541 sha_de->ref_blks = de->u.de.ref_blks;
542 sha_de->ref_size = de->u.de.ref_size;
543 if (upgrade_chksum(&sha_de->leaf, sha_de->sha_hash)) {
548 RB_INIT(&de->u.fict_root);
550 * Here we can insert without prior checking because the tree
551 * is empty at this point
553 RB_INSERT(sha_dedup_entry_rb_tree, &de->u.fict_root, sha_de);
556 * Mark entry in CRC tree fictitious
558 de->flags |= HAMMER_DEDUP_ENTRY_FICTITIOUS;
561 * Upgrade checksum of the candidate and insert it into
562 * SHA subtree. If upgrade fails insert the candidate into
565 if (upgrade_chksum(scan_leaf, temp.sha_hash)) {
568 sha_de = RB_FIND(sha_dedup_entry_rb_tree, &de->u.fict_root, &temp);
570 /* There is an entry with this SHA already, but the only
571 * RB-tree element at this point is that entry we just
572 * added. We know for sure these blocks are different
573 * (this is crc_failure branch) so treat it as SHA
578 sha_de = calloc(sizeof(*sha_de), 1);
579 sha_de->leaf = *scan_leaf;
580 memcpy(sha_de->sha_hash, temp.sha_hash, SHA256_DIGEST_LENGTH);
581 RB_INSERT(sha_dedup_entry_rb_tree, &de->u.fict_root, sha_de);
582 goto upgrade_stats_sha;
586 de->u.de.ref_blks += 1;
587 de->u.de.ref_size += scan_leaf->data_len;
591 sha_de->ref_blks += 1;
592 sha_de->ref_size += scan_leaf->data_len;
597 * If in pass2 mode don't insert anything, fall through to
600 if ((flags & DEDUP_PASS2) == 0) {
601 pass2_de = calloc(sizeof(*pass2_de), 1);
602 pass2_de->leaf = *scan_leaf;
603 STAILQ_INSERT_TAIL(&pass2_dedup_queue, pass2_de, sq_entry);
604 dedup_skipped_size += scan_leaf->data_len;
610 * Early termination path. Fixup stats.
612 dedup_alloc_size += scan_leaf->data_len;
613 dedup_ref_size += scan_leaf->data_len;
618 upgrade_chksum(hammer_btree_leaf_elm_t leaf, u_int8_t *sha_hash)
620 struct hammer_ioc_data data;
621 char *buf = malloc(DEDUP_BUF);
625 bzero(&data, sizeof(data));
626 data.elm = leaf->base;
628 data.size = DEDUP_BUF;
631 if (ioctl(glob_fd, HAMMERIOC_GET_DATA, &data) < 0) {
632 fprintf(stderr, "Get-data failed: %s\n", strerror(errno));
637 if (data.leaf.data_len != leaf->data_len) {
642 if (data.leaf.base.btype == HAMMER_BTREE_TYPE_RECORD &&
643 data.leaf.base.rec_type == HAMMER_RECTYPE_DATA) {
645 SHA256_Update(&ctx, (void *)buf, data.leaf.data_len);
646 SHA256_Final(sha_hash, &ctx);
655 scan_pfs(char *filesystem, scan_pfs_cb_t func)
657 struct hammer_ioc_mirror_rw mirror;
658 hammer_ioc_mrecord_any_t mrec;
659 struct hammer_btree_leaf_elm elm;
660 char *buf = malloc(DEDUP_BUF);
663 bzero(&mirror, sizeof(mirror));
664 hammer_key_beg_init(&mirror.key_beg);
665 hammer_key_end_init(&mirror.key_end);
667 mirror.tid_beg = glob_pfs.ondisk->sync_beg_tid;
668 mirror.tid_end = glob_pfs.ondisk->sync_end_tid;
669 mirror.head.flags |= HAMMER_IOC_MIRROR_NODATA; /* we want only keys */
671 mirror.size = DEDUP_BUF;
672 mirror.pfs_id = glob_pfs.pfs_id;
673 mirror.shared_uuid = glob_pfs.ondisk->shared_uuid;
675 printf("%s: objspace %016jx:%04x %016jx:%04x pfs_id %d\n",
677 (uintmax_t)mirror.key_beg.obj_id,
678 mirror.key_beg.localization,
679 (uintmax_t)mirror.key_end.obj_id,
680 mirror.key_end.localization,
686 mirror.pfs_id = glob_pfs.pfs_id;
687 mirror.shared_uuid = glob_pfs.ondisk->shared_uuid;
688 if (ioctl(glob_fd, HAMMERIOC_MIRROR_READ, &mirror) < 0) {
689 fprintf(stderr, "Mirror-read %s failed: %s\n",
690 filesystem, strerror(errno));
693 if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR) {
694 fprintf(stderr, "Mirror-read %s fatal error %d\n",
695 filesystem, mirror.head.error);
700 while (offset < mirror.count) {
701 mrec = (void *)((char *)buf + offset);
702 bytes = HAMMER_HEAD_DOALIGN(mrec->head.rec_size);
703 if (offset + bytes > mirror.count) {
704 fprintf(stderr, "Misaligned record\n");
707 assert((mrec->head.type &
708 HAMMER_MRECF_TYPE_MASK) == HAMMER_MREC_TYPE_REC);
710 elm = mrec->rec.leaf;
711 if (elm.base.btype == HAMMER_BTREE_TYPE_RECORD &&
712 elm.base.rec_type == HAMMER_RECTYPE_DATA) {
718 mirror.key_beg = mirror.key_cur;
719 } while (mirror.count != 0);
725 dump_simulated_dedup(void)
727 struct sim_dedup_entry *sim_de;
729 printf("=== Dumping simulated dedup entries:\n");
730 RB_FOREACH(sim_de, sim_dedup_entry_rb_tree, &sim_dedup_tree) {
731 printf("\tcrc=%08x cnt=%ju size=%ju\n",
733 (intmax_t)sim_de->ref_blks,
734 (intmax_t)sim_de->ref_size);
736 printf("end of dump ===\n");
740 dump_real_dedup(void)
742 struct dedup_entry *de;
743 struct sha_dedup_entry *sha_de;
746 printf("=== Dumping dedup entries:\n");
747 RB_FOREACH(de, dedup_entry_rb_tree, &dedup_tree) {
748 if (de->flags & HAMMER_DEDUP_ENTRY_FICTITIOUS) {
749 printf("\tcrc=%08x fictitious\n", de->leaf.data_crc);
751 RB_FOREACH(sha_de, sha_dedup_entry_rb_tree, &de->u.fict_root) {
752 printf("\t\tcrc=%08x cnt=%ju size=%ju\n\t"
754 sha_de->leaf.data_crc,
755 (intmax_t)sha_de->ref_blks,
756 (intmax_t)sha_de->ref_size);
757 for (i = 0; i < SHA256_DIGEST_LENGTH; ++i)
758 printf("%02x", sha_de->sha_hash[i]);
762 printf("\tcrc=%08x cnt=%ju size=%ju\n",
764 (intmax_t)de->u.de.ref_blks,
765 (intmax_t)de->u.de.ref_size);
768 printf("end of dump ===\n");
772 dedup_usage(int code)
775 "hammer dedup-simulate <filesystem>\n"
776 "hammer dedup <filesystem>\n"