Loading newbrt/Makefile +5 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ LDLIBS+=-lnewbrt -l$(LIBTOKUPORTABILITY) BINS_RAW= \ brtdump \ brtdump_static \ tdb_logprint \ tdb-recover \ # Intentionally left blank Loading Loading @@ -179,6 +180,10 @@ clean-local: rm -rf test_oexcl.c.tmp *.brt rm -rf log_code.c log_header.h log_print.c logformat brtdump_static$(BINSUF): DEPEND_LINK = -lpthread -ldl -lz brtdump_static$(BINSUF): brtdump.$(OEXT) $(NEWBRT_A) $(LIBPORTABILITY_A) $(DEPEND_COMPILE) $(DEPEND_LINK) $(CC) $< $(NEWBRT_A) $(LIBPORTABILITY_A) $(BIN_FROM_O_FLAGS_NOLIB) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST) # After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences. testdump: brtdump$(BINSUF) ./brtdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./brtdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.$(OEXT) && diff dump.$(OEXT) dump.r Loading newbrt/brtdump.c +55 −0 Original line number Diff line number Diff line Loading @@ -262,6 +262,59 @@ dump_fragmentation(int f, struct brt_header *h) { printf("fragmentation: %.1f%%\n", 100. * ((double)fragsizes / (double)(total_space))); } typedef struct { int f; struct brt_header *h; size_t total_space; size_t used_space; } garbage_help_extra; static int garbage_leafentry_helper(OMTVALUE v, u_int32_t UU(idx), void *extra) { garbage_help_extra *info = extra; LEAFENTRY le = v; info->total_space += leafentry_disksize(le); info->used_space += LE_CLEAN_MEMSIZE(le_latest_keylen(le), le_latest_vallen(le)); return 0; } static int garbage_helper(BLOCKNUM b, int64_t UU(size), int64_t UU(address), void *extra) { garbage_help_extra *info = extra; BRTNODE n; struct brtnode_fetch_extra bfe; fill_bfe_for_full_read(&bfe, info->h); int r = toku_deserialize_brtnode_from(info->f, b, 0, &n, &bfe); if (r != 0) { goto exit; } if (n->height > 0) { goto exit; } for (int i = 0; i < n->n_children; ++i) { BASEMENTNODE bn = BLB(n, i); r = toku_omt_iterate(bn->buffer, garbage_leafentry_helper, info); if (r != 0) { goto exit; } } exit: return r; } static void dump_garbage_stats(int f, struct brt_header *h) { garbage_help_extra info; memset(&info, 0, sizeof info); info.f = f; info.h = h; toku_blocktable_iterate(h->blocktable, TRANSLATION_CHECKPOINTED, garbage_helper, &info, TRUE, TRUE); printf("total_size: %zu\n", info.total_space); printf("used_size: %zu\n", info.used_space); } static u_int32_t get_unaligned_uint32(unsigned char *p) { return *(u_int32_t *)p; Loading Loading @@ -483,6 +536,8 @@ main (int argc, const char *const argv[]) { dump_block_translation(h, offset); } else if (strcmp(fields[0], "fragmentation") == 0) { dump_fragmentation(f, h); } else if (strcmp(fields[0], "garbage") == 0) { dump_garbage_stats(f, h); } else if (strcmp(fields[0], "file") == 0 && nfields >= 3) { u_int64_t offset = getuint64(fields[1]); u_int64_t size = getuint64(fields[2]); Loading Loading
newbrt/Makefile +5 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ LDLIBS+=-lnewbrt -l$(LIBTOKUPORTABILITY) BINS_RAW= \ brtdump \ brtdump_static \ tdb_logprint \ tdb-recover \ # Intentionally left blank Loading Loading @@ -179,6 +180,10 @@ clean-local: rm -rf test_oexcl.c.tmp *.brt rm -rf log_code.c log_header.h log_print.c logformat brtdump_static$(BINSUF): DEPEND_LINK = -lpthread -ldl -lz brtdump_static$(BINSUF): brtdump.$(OEXT) $(NEWBRT_A) $(LIBPORTABILITY_A) $(DEPEND_COMPILE) $(DEPEND_LINK) $(CC) $< $(NEWBRT_A) $(LIBPORTABILITY_A) $(BIN_FROM_O_FLAGS_NOLIB) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST) # After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences. testdump: brtdump$(BINSUF) ./brtdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./brtdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.$(OEXT) && diff dump.$(OEXT) dump.r Loading
newbrt/brtdump.c +55 −0 Original line number Diff line number Diff line Loading @@ -262,6 +262,59 @@ dump_fragmentation(int f, struct brt_header *h) { printf("fragmentation: %.1f%%\n", 100. * ((double)fragsizes / (double)(total_space))); } typedef struct { int f; struct brt_header *h; size_t total_space; size_t used_space; } garbage_help_extra; static int garbage_leafentry_helper(OMTVALUE v, u_int32_t UU(idx), void *extra) { garbage_help_extra *info = extra; LEAFENTRY le = v; info->total_space += leafentry_disksize(le); info->used_space += LE_CLEAN_MEMSIZE(le_latest_keylen(le), le_latest_vallen(le)); return 0; } static int garbage_helper(BLOCKNUM b, int64_t UU(size), int64_t UU(address), void *extra) { garbage_help_extra *info = extra; BRTNODE n; struct brtnode_fetch_extra bfe; fill_bfe_for_full_read(&bfe, info->h); int r = toku_deserialize_brtnode_from(info->f, b, 0, &n, &bfe); if (r != 0) { goto exit; } if (n->height > 0) { goto exit; } for (int i = 0; i < n->n_children; ++i) { BASEMENTNODE bn = BLB(n, i); r = toku_omt_iterate(bn->buffer, garbage_leafentry_helper, info); if (r != 0) { goto exit; } } exit: return r; } static void dump_garbage_stats(int f, struct brt_header *h) { garbage_help_extra info; memset(&info, 0, sizeof info); info.f = f; info.h = h; toku_blocktable_iterate(h->blocktable, TRANSLATION_CHECKPOINTED, garbage_helper, &info, TRUE, TRUE); printf("total_size: %zu\n", info.total_space); printf("used_size: %zu\n", info.used_space); } static u_int32_t get_unaligned_uint32(unsigned char *p) { return *(u_int32_t *)p; Loading Loading @@ -483,6 +536,8 @@ main (int argc, const char *const argv[]) { dump_block_translation(h, offset); } else if (strcmp(fields[0], "fragmentation") == 0) { dump_fragmentation(f, h); } else if (strcmp(fields[0], "garbage") == 0) { dump_garbage_stats(f, h); } else if (strcmp(fields[0], "file") == 0 && nfields >= 3) { u_int64_t offset = getuint64(fields[1]); u_int64_t size = getuint64(fields[2]); Loading