2 * Copyright (c) 2008 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.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
39 #define FLAG_TOOFARLEFT 0x0001
40 #define FLAG_TOOFARRIGHT 0x0002
41 #define FLAG_BADTYPE 0x0004
42 #define FLAG_BADCHILDPARENT 0x0008
43 #define FLAG_BADMIRRORTID 0x0010
45 typedef struct btree_search {
50 hammer_tid_t create_tid;
51 int limit; /* # of fields to test */
52 int filter; /* filter type (default -1) */
55 static void print_btree_node(hammer_off_t node_offset, btree_search_t search,
56 int depth, hammer_tid_t mirror_tid,
57 hammer_base_elm_t left_bound,
58 hammer_base_elm_t right_bound,
59 struct zone_stat *stats);
60 static const char *check_data_crc(hammer_btree_elm_t elm);
61 static void print_record(hammer_btree_elm_t elm);
62 static void print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type,
63 int flags, const char *label, const char *ext,
64 struct zone_stat *stats);
65 static int get_elm_flags(hammer_node_ondisk_t node, hammer_off_t node_offset,
66 hammer_btree_elm_t elm, int i,
67 hammer_base_elm_t left_bound,
68 hammer_base_elm_t right_bound);
69 static int test_lr(hammer_btree_elm_t elm,
70 hammer_base_elm_t left_bound,
71 hammer_base_elm_t right_bound);
72 static int test_rbn_lr(hammer_btree_elm_t elm,
73 hammer_base_elm_t left_bound,
74 hammer_base_elm_t right_bound);
75 static void print_bigblock_fill(hammer_off_t offset);
76 static int init_btree_search(const char *arg, int filter,
77 btree_search_t search);
78 static int test_btree_search(hammer_btree_elm_t elm, btree_search_t search);
80 static int num_bad_node = 0;
81 static int num_bad_elm = 0;
84 hammer_cmd_show(hammer_off_t node_offset, const char *arg,
85 int filter, int depth,
86 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
88 struct volume_info *volume;
89 struct btree_search search;
90 btree_search_t searchp = NULL;
91 struct zone_stat *stats = NULL;
94 AssertOnFailure = (DebugOpt != 0);
97 stats = hammer_init_zone_stat_bits();
99 if (node_offset == (hammer_off_t)-1) {
100 volume = get_volume(RootVolNo);
101 node_offset = volume->ondisk->vol0_btree_root;
103 printf("Volume header\trecords=%jd next_tid=%016jx\n",
104 (intmax_t)volume->ondisk->vol0_stat_records,
105 (uintmax_t)volume->ondisk->vol0_next_tid);
106 printf("\t\tbufoffset=%016jx\n",
107 (uintmax_t)volume->ondisk->vol_buf_beg);
108 for (zone = 0; zone < HAMMER_MAX_ZONES; ++zone) {
109 printf("\t\tzone %d\tnext_offset=%016jx\n",
111 (uintmax_t)volume->ondisk->vol0_blockmap[zone].next_offset
118 printf("show %016jx", (uintmax_t)node_offset);
120 assert(init_btree_search(arg, filter, &search) != -1);
121 if (search.limit >= 1)
122 printf(" lo %08x obj_id %016jx",
123 search.lo, (uintmax_t)search.obj_id);
124 if (search.limit >= 3)
125 printf(" rec_type %02x", search.rec_type);
126 if (search.limit >= 4)
127 printf(" key %016jx", (uintmax_t)search.key);
128 if (search.limit == 5)
129 printf(" create_tid %016jx\n",
130 (uintmax_t)search.create_tid);
133 printf(" depth %d\n", depth);
134 print_btree_node(node_offset, searchp, depth, HAMMER_MAX_TID,
135 left_bound, right_bound, stats);
140 hammer_print_zone_stat(stats);
141 hammer_cleanup_zone_stat(stats);
144 if (num_bad_node || VerboseOpt) {
145 printf("%d bad nodes\n", num_bad_node);
147 if (num_bad_elm || VerboseOpt) {
148 printf("%d bad elms\n", num_bad_elm);
153 print_btree_node(hammer_off_t node_offset, btree_search_t search,
154 int depth, hammer_tid_t mirror_tid,
155 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound,
156 struct zone_stat *stats)
158 struct buffer_info *buffer = NULL;
159 hammer_node_ondisk_t node;
160 hammer_btree_elm_t elm;
164 char badc = ' '; /* good */
165 char badm = ' '; /* good */
168 node = get_node(node_offset, &buffer);
174 if (crc32(&node->crc + 1, HAMMER_BTREE_CRCSIZE) != node->crc)
176 if (node->mirror_tid > mirror_tid) {
180 maxcount = hammer_node_max_elements(node->type);
181 if (maxcount == -1) {
184 } else if (node->count == 0 || node->count > maxcount) {
190 if (badm != ' ' || badc != ' ') /* not good */
193 printf("%c%c NODE %016jx ", badc, badm, (uintmax_t)node_offset);
195 printf("(IO ERROR)\n");
200 printf("cnt=%02d p=%016jx type=%c depth=%d mirror=%016jx",
202 (uintmax_t)node->parent,
203 (node->type ? node->type : '?'),
205 (uintmax_t)node->mirror_tid);
208 print_bigblock_fill(node_offset);
211 printf(" sign=%04x", node->signature);
215 hammer_add_zone_stat(stats, node_offset, sizeof(*node));
217 for (i = 0; i < node->count; ++i) {
218 elm = &node->elms[i];
220 if (node->type != HAMMER_BTREE_TYPE_INTERNAL) {
222 if (search && test_btree_search(elm, search) == 0)
226 if (test_btree_search(elm, search) > 0 ||
227 test_btree_search(elm + 1, search) < 0)
233 flags = get_elm_flags(node, node_offset, elm, i,
234 left_bound, right_bound);
235 print_btree_elm(elm, i, node->type, flags, "ELM", ext, stats);
237 if (node->type == HAMMER_BTREE_TYPE_INTERNAL) {
238 assert(i == node->count); /* boundary */
239 elm = &node->elms[i];
241 flags = get_elm_flags(node, node_offset, elm, i,
242 left_bound, right_bound);
243 print_btree_elm(elm, i, node->type, flags, "RBN", NULL, stats);
247 for (i = 0; i < node->count; ++i) {
248 elm = &node->elms[i];
251 case HAMMER_BTREE_TYPE_INTERNAL:
252 if (search && search->filter) {
253 if (test_btree_search(elm, search) > 0 ||
254 test_btree_search(elm + 1, search) < 0)
257 if (elm->internal.subtree_offset) {
258 print_btree_node(elm->internal.subtree_offset,
260 elm->internal.mirror_tid,
261 &elm[0].base, &elm[1].base,
264 * Cause show to do normal iteration after
265 * seeking to the lo:objid:rectype:key:tid
268 if (search && search->filter == -1) /* default */
281 is_root_btree_beg(u_int8_t type, int i, hammer_btree_elm_t elm)
284 * elm->base.btype depends on what the original node had
285 * so it could be anything but HAMMER_BTREE_TYPE_NONE.
287 return (type == HAMMER_BTREE_TYPE_INTERNAL &&
289 elm->base.localization == 0 &&
290 elm->base.obj_id == (int64_t)-0x8000000000000000LL &&
291 elm->base.key == (int64_t)-0x8000000000000000LL &&
292 elm->base.create_tid == 1 &&
293 elm->base.delete_tid == 1 &&
294 elm->base.rec_type == 0 &&
295 elm->base.obj_type == 0 &&
296 elm->base.btype != HAMMER_BTREE_TYPE_NONE);
301 is_root_btree_end(u_int8_t type, int i, hammer_btree_elm_t elm)
303 return (type == HAMMER_BTREE_TYPE_INTERNAL &&
305 elm->base.localization == 0xFFFFFFFFU &&
306 elm->base.obj_id == 0x7FFFFFFFFFFFFFFFLL &&
307 elm->base.key == 0x7FFFFFFFFFFFFFFFLL &&
308 elm->base.create_tid == 0xFFFFFFFFFFFFFFFFULL &&
309 elm->base.delete_tid == 0 &&
310 elm->base.rec_type == 0xFFFFU &&
311 elm->base.obj_type == 0 &&
312 elm->base.btype == HAMMER_BTREE_TYPE_NONE);
317 print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type,
318 int flags, const char *label, const char *ext,
319 struct zone_stat *stats)
321 char flagstr[8] = { 0, '-', '-', '-', '-', '-', '-', 0 };
325 flagstr[0] = flags ? 'B' : 'G';
326 if (flags & FLAG_TOOFARLEFT)
328 if (flags & FLAG_TOOFARRIGHT)
330 if (flags & FLAG_BADTYPE)
332 if (flags & FLAG_BADCHILDPARENT)
334 if (flags & FLAG_BADMIRRORTID)
336 if (flagstr[0] == 'B')
340 * Check if elm is derived from root split
342 if (is_root_btree_beg(type, i, elm))
344 else if (is_root_btree_end(type, i, elm))
349 if (elm->base.delete_tid)
354 printf("%s\t%s %2d %c ", flagstr, label, i, hammer_elm_btype(elm));
355 printf("lo=%08x obj=%016jx rt=%02x key=%016jx ot=%02x\n",
356 elm->base.localization,
357 (uintmax_t)elm->base.obj_id,
359 (uintmax_t)elm->base.key,
361 printf("\t %c tids=%016jx:%016jx ",
362 (rootelm == ' ' ? deleted : rootelm),
363 (uintmax_t)elm->base.create_tid,
364 (uintmax_t)elm->base.delete_tid);
367 case HAMMER_BTREE_TYPE_INTERNAL:
368 printf("suboff=%016jx",
369 (uintmax_t)elm->internal.subtree_offset);
371 printf(" mirror=%016jx",
372 (uintmax_t)elm->internal.mirror_tid);
377 case HAMMER_BTREE_TYPE_LEAF:
380 switch(elm->base.btype) {
381 case HAMMER_BTREE_TYPE_RECORD:
383 printf("\n%s\t ", check_data_crc(elm));
386 printf("dataoff=%016jx/%d",
387 (uintmax_t)elm->leaf.data_offset,
390 printf(" crc=%04x", elm->leaf.data_crc);
391 printf("\n\t fill=");
392 print_bigblock_fill(elm->leaf.data_offset);
397 hammer_add_zone_stat(stats,
398 elm->leaf.data_offset,
403 printf("badtype=%d", elm->base.btype);
415 get_elm_flags(hammer_node_ondisk_t node, hammer_off_t node_offset,
416 hammer_btree_elm_t elm, int i,
417 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
419 hammer_off_t child_offset;
423 case HAMMER_BTREE_TYPE_INTERNAL:
424 child_offset = elm->internal.subtree_offset;
425 if (elm->internal.mirror_tid > node->mirror_tid)
426 flags |= FLAG_BADMIRRORTID;
428 if (i == node->count) {
429 if (child_offset != 0)
430 flags |= FLAG_BADCHILDPARENT;
431 switch(elm->base.btype) {
432 case HAMMER_BTREE_TYPE_NONE:
433 flags |= test_rbn_lr(elm, left_bound, right_bound);
436 flags |= FLAG_BADTYPE;
440 if (child_offset == 0) {
441 flags |= FLAG_BADCHILDPARENT;
443 struct buffer_info *buffer = NULL;
444 hammer_node_ondisk_t subnode;
445 subnode = get_node(child_offset, &buffer);
447 flags |= FLAG_BADCHILDPARENT;
448 else if (subnode->parent != node_offset)
449 flags |= FLAG_BADCHILDPARENT;
452 switch(elm->base.btype) {
453 case HAMMER_BTREE_TYPE_INTERNAL:
454 case HAMMER_BTREE_TYPE_LEAF:
455 flags |= test_lr(elm, left_bound, right_bound);
458 flags |= FLAG_BADTYPE;
463 case HAMMER_BTREE_TYPE_LEAF:
464 if (elm->leaf.data_offset == 0) {
465 flags |= FLAG_BADCHILDPARENT;
467 if (elm->leaf.data_len == 0) {
468 flags |= FLAG_BADCHILDPARENT;
471 if (node->mirror_tid == 0 &&
472 !(node->parent == 0 && node->count == 2)) {
473 flags |= FLAG_BADMIRRORTID;
475 if (elm->base.create_tid && node->mirror_tid &&
476 elm->base.create_tid > node->mirror_tid) {
477 flags |= FLAG_BADMIRRORTID;
479 if (elm->base.delete_tid && node->mirror_tid &&
480 elm->base.delete_tid > node->mirror_tid) {
481 flags |= FLAG_BADMIRRORTID;
483 switch(elm->base.btype) {
484 case HAMMER_BTREE_TYPE_RECORD:
485 flags |= test_lr(elm, left_bound, right_bound);
488 flags |= FLAG_BADTYPE;
493 flags |= FLAG_BADTYPE;
501 test_lr(hammer_btree_elm_t elm,
502 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
504 if (left_bound == NULL || right_bound == NULL)
506 if (hammer_btree_cmp(&elm->base, left_bound) < 0)
507 return(FLAG_TOOFARLEFT);
508 if (hammer_btree_cmp(&elm->base, right_bound) >= 0)
509 return(FLAG_TOOFARRIGHT);
515 test_rbn_lr(hammer_btree_elm_t rbn,
516 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
518 if (left_bound == NULL || right_bound == NULL)
520 if (hammer_btree_cmp(&rbn->base, left_bound) < 0)
521 return(FLAG_TOOFARLEFT);
522 if (hammer_btree_cmp(&rbn->base, right_bound) > 0)
523 return(FLAG_TOOFARRIGHT);
529 print_bigblock_fill(hammer_off_t offset)
531 struct hammer_blockmap_layer1 layer1;
532 struct hammer_blockmap_layer2 layer2;
536 blockmap_lookup(offset, &layer1, &layer2, &error);
537 printf("z%d:v%d:%lu:%lu:%lu=",
538 HAMMER_ZONE_DECODE(offset),
539 HAMMER_VOL_DECODE(offset),
540 HAMMER_BLOCKMAP_LAYER1_INDEX(offset),
541 HAMMER_BLOCKMAP_LAYER2_INDEX(offset),
542 offset & HAMMER_BIGBLOCK_MASK64);
545 printf("B%d", error);
547 fill = layer2.bytes_free * 100 / HAMMER_BIGBLOCK_SIZE;
549 printf("%d%%", fill);
554 * Check the generic crc on a data element. Inodes record types are
555 * special in that some of their fields are not CRCed.
557 * Also check that the zone is valid.
561 check_data_crc(hammer_btree_elm_t elm)
563 struct buffer_info *data_buffer;
564 hammer_off_t data_offset;
571 data_offset = elm->leaf.data_offset;
572 data_len = elm->leaf.data_len;
574 if (data_offset == 0 || data_len == 0)
580 blockmap_lookup(data_offset, NULL, NULL, &error);
584 ptr = get_buffer_data(data_offset, &data_buffer, 0);
585 len = HAMMER_BUFSIZE - ((int)data_offset & HAMMER_BUFMASK);
588 if (elm->leaf.base.rec_type == HAMMER_RECTYPE_INODE &&
589 data_len == sizeof(struct hammer_inode_data)) {
590 crc = crc32_ext(ptr, HAMMER_INODE_CRCSIZE, crc);
592 crc = crc32_ext(ptr, len, crc);
597 rel_buffer(data_buffer);
599 switch (error) { /* bad offset */
622 if (crc == elm->leaf.data_crc)
624 return("BX"); /* bad crc */
629 print_config(char *cfgtxt)
633 printf("\n%17stext=\"\n", "");
634 while((token = strsep(&cfgtxt, "\r\n")) != NULL) {
635 printf("%17s %s\n", "", token);
637 printf("%17s\"", "");
642 print_record(hammer_btree_elm_t elm)
644 struct buffer_info *data_buffer;
645 hammer_off_t data_offset;
647 hammer_data_ondisk_t data;
652 data_offset = elm->leaf.data_offset;
653 data_len = elm->leaf.data_len;
654 assert(data_offset != 0);
655 assert(data_len != 0);
658 data = get_buffer_data(data_offset, &data_buffer, 0);
659 assert(data != NULL);
661 switch(elm->leaf.base.rec_type) {
662 case HAMMER_RECTYPE_UNKNOWN:
663 printf("\n%17s", "");
666 case HAMMER_RECTYPE_INODE:
667 printf("\n%17s", "");
668 printf("size=%jd nlinks=%jd",
669 (intmax_t)data->inode.size,
670 (intmax_t)data->inode.nlinks);
672 printf(" mode=%05o uflags=%08x\n",
676 printf("ctime=%016jx pobjid=%016jx obj_type=%d\n",
677 (uintmax_t)data->inode.ctime,
678 (uintmax_t)data->inode.parent_obj_id,
679 data->inode.obj_type);
681 printf("mtime=%016jx", (uintmax_t)data->inode.mtime);
682 printf(" caps=%02x", data->inode.cap_flags);
685 case HAMMER_RECTYPE_DIRENTRY:
686 printf("\n%17s", "");
687 data_len -= HAMMER_ENTRY_NAME_OFF;
688 printf("dir-entry ino=%016jx lo=%08x name=\"%*.*s\"",
689 (uintmax_t)data->entry.obj_id,
690 data->entry.localization,
691 data_len, data_len, data->entry.name);
693 case HAMMER_RECTYPE_FIX:
694 switch(elm->leaf.base.key) {
695 case HAMMER_FIXKEY_SYMLINK:
696 data_len -= HAMMER_SYMLINK_NAME_OFF;
697 printf("\n%17s", "");
698 printf("symlink=\"%*.*s\"", data_len, data_len,
705 case HAMMER_RECTYPE_PFS:
706 printf("\n%17s", "");
707 printf("sync_beg_tid=%016jx sync_end_tid=%016jx\n",
708 (intmax_t)data->pfsd.sync_beg_tid,
709 (intmax_t)data->pfsd.sync_end_tid);
710 uuid_to_string(&data->pfsd.shared_uuid, &str1, &status);
711 uuid_to_string(&data->pfsd.unique_uuid, &str2, &status);
713 printf("shared_uuid=%s\n", str1);
715 printf("unique_uuid=%s\n", str2);
717 printf("mirror_flags=%08x label=\"%s\"",
718 data->pfsd.mirror_flags, data->pfsd.label);
719 if (data->pfsd.snapshots[0])
720 printf(" snapshots=\"%s\"", data->pfsd.snapshots);
724 case HAMMER_RECTYPE_SNAPSHOT:
725 printf("\n%17s", "");
726 printf("tid=%016jx label=\"%s\"",
727 (intmax_t)data->snap.tid, data->snap.label);
729 case HAMMER_RECTYPE_CONFIG:
730 if (VerboseOpt > 2) {
731 print_config(data->config.text);
734 case HAMMER_RECTYPE_DATA:
735 if (VerboseOpt > 3) {
737 hexdump(data, data_len, "\t\t ", 0);
740 case HAMMER_RECTYPE_EXT:
741 case HAMMER_RECTYPE_DB:
742 if (VerboseOpt > 2) {
744 hexdump(data, data_len, "\t\t ", 0);
751 rel_buffer(data_buffer);
756 _strtoul(const char *p, int base)
758 unsigned long retval;
760 errno = 0; /* clear */
761 retval = strtoul(p, NULL, base);
762 if (errno == ERANGE && retval == ULONG_MAX)
769 _strtoull(const char *p, int base)
771 unsigned long long retval;
773 errno = 0; /* clear */
774 retval = strtoull(p, NULL, base);
775 if (errno == ERANGE && retval == ULLONG_MAX)
781 init_btree_search(const char *arg, int filter, btree_search_t search)
787 search->obj_id = (int64_t)HAMMER_MIN_OBJID;
788 search->rec_type = HAMMER_RECTYPE_LOWEST;
790 search->create_tid = 0;
792 search->filter = filter;
798 while ((p = s) != NULL) {
799 if ((s = strchr(s, ':')) != NULL)
802 search->lo = _strtoul(p, 16);
804 search->obj_id = _strtoull(p, 16);
806 search->rec_type = _strtoul(p, 16);
808 search->key = _strtoull(p, 16);
810 search->create_tid = _strtoull(p, 16);
820 test_btree_search(hammer_btree_elm_t elm, btree_search_t search)
822 hammer_base_elm_t base = &elm->base;
825 if (base->localization < search->lo)
827 if (base->localization > search->lo)
831 if (base->obj_id < search->obj_id)
833 if (base->obj_id > search->obj_id)
835 if (search->limit == 2)
836 return(0); /* ignore below */
838 if (base->rec_type < search->rec_type)
840 if (base->rec_type > search->rec_type)
842 if (search->limit == 3)
843 return(0); /* ignore below */
845 if (base->key < search->key)
847 if (base->key > search->key)
849 if (search->limit == 4)
850 return(0); /* ignore below */
852 if (base->create_tid == 0) {
853 if (search->create_tid == 0)
857 if (search->create_tid == 0)
859 if (base->create_tid < search->create_tid)
861 if (base->create_tid > search->create_tid)
870 hammer_cmd_show_undo(void)
872 struct volume_info *volume;
873 hammer_blockmap_t rootmap;
874 hammer_off_t scan_offset;
875 hammer_fifo_any_t head;
876 struct buffer_info *data_buffer = NULL;
879 volume = get_volume(RootVolNo);
880 rootmap = &volume->ondisk->vol0_blockmap[HAMMER_ZONE_UNDO_INDEX];
881 if (rootmap->first_offset <= rootmap->next_offset)
882 bytes = rootmap->next_offset - rootmap->first_offset;
884 bytes = rootmap->alloc_offset - rootmap->first_offset +
885 (rootmap->next_offset & HAMMER_OFF_LONG_MASK);
887 printf("Volume header UNDO %016jx-%016jx/%016jx\n",
888 (intmax_t)rootmap->first_offset,
889 (intmax_t)rootmap->next_offset,
890 (intmax_t)rootmap->alloc_offset);
891 printf("UNDO map is %jdMB\n",
892 (intmax_t)((rootmap->alloc_offset & HAMMER_OFF_LONG_MASK) /
894 printf("UNDO being used is %jdB\n", (intmax_t)bytes);
896 scan_offset = HAMMER_ZONE_ENCODE(HAMMER_ZONE_UNDO_INDEX, 0);
897 while (scan_offset < rootmap->alloc_offset) {
898 head = get_buffer_data(scan_offset, &data_buffer, 0);
899 printf("%016jx ", scan_offset);
901 switch(head->head.hdr_type) {
902 case HAMMER_HEAD_TYPE_PAD:
903 printf("PAD(%04x)", head->head.hdr_size);
905 case HAMMER_HEAD_TYPE_DUMMY:
906 printf("DUMMY(%04x) seq=%08x",
907 head->head.hdr_size, head->head.hdr_seq);
909 case HAMMER_HEAD_TYPE_UNDO:
910 printf("UNDO(%04x) seq=%08x "
911 "dataoff=%016jx bytes=%d",
912 head->head.hdr_size, head->head.hdr_seq,
913 (intmax_t)head->undo.undo_offset,
914 head->undo.undo_data_bytes);
916 case HAMMER_HEAD_TYPE_REDO:
917 printf("REDO(%04x) seq=%08x flags=%08x "
918 "objid=%016jx logoff=%016jx bytes=%d",
919 head->head.hdr_size, head->head.hdr_seq,
920 head->redo.redo_flags,
921 (intmax_t)head->redo.redo_objid,
922 (intmax_t)head->redo.redo_offset,
923 head->redo.redo_data_bytes);
926 printf("UNKNOWN(%04x,%04x) seq=%08x",
933 if (scan_offset == rootmap->first_offset)
935 if (scan_offset == rootmap->next_offset)
939 if ((head->head.hdr_size & HAMMER_HEAD_ALIGN_MASK) ||
940 head->head.hdr_size == 0 ||
941 head->head.hdr_size > HAMMER_UNDO_ALIGN -
942 ((u_int)scan_offset & HAMMER_UNDO_MASK)) {
943 printf("Illegal size field, skipping to "
945 scan_offset = (scan_offset + HAMMER_UNDO_MASK) &
948 scan_offset += head->head.hdr_size;
951 rel_buffer(data_buffer);