2013-04-16 23:57:21 -04:00
|
|
|
|
2008-01-18 16:01:25 +00:00
|
|
|
/* Tell me the diff between two brt files. */
|
2008-02-08 03:17:38 +00:00
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
#include "includes.h"
|
2008-01-18 16:01:25 +00:00
|
|
|
|
2008-04-30 13:23:04 +00:00
|
|
|
static int dump_data = 1;
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static void
|
|
|
|
print_item (bytevec val, ITEMLEN len) {
|
2008-04-27 17:54:24 +00:00
|
|
|
printf("\"");
|
|
|
|
ITEMLEN i;
|
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
unsigned char ch = ((unsigned char*)val)[i];
|
|
|
|
if (isprint(ch) && ch!='\\' && ch!='"') {
|
|
|
|
printf("%c", ch);
|
|
|
|
} else {
|
|
|
|
printf("\\%03o", ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\"");
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static void
|
|
|
|
dump_header (int f, struct brt_header **header) {
|
2008-01-18 16:01:25 +00:00
|
|
|
struct brt_header *h;
|
|
|
|
int r;
|
2013-04-16 23:57:18 -04:00
|
|
|
r = toku_deserialize_brtheader_from (f, header_blocknum, &h); assert(r==0);
|
2008-01-18 16:01:25 +00:00
|
|
|
printf("brtheader:\n");
|
2008-05-22 21:28:00 +00:00
|
|
|
if (h->layout_version==BRT_LAYOUT_VERSION_6) printf(" layout_version<=6\n");
|
|
|
|
else printf(" layout_version=%d\n", h->layout_version);
|
2008-01-18 16:01:25 +00:00
|
|
|
printf(" dirty=%d\n", h->dirty);
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" nodesize=%u\n", h->nodesize);
|
2013-04-16 23:57:41 -04:00
|
|
|
BLOCKNUM free_blocks = toku_block_get_free_blocks(h->blocktable);
|
|
|
|
BLOCKNUM unused_blocks = toku_block_get_unused_blocks(h->blocktable);
|
|
|
|
printf(" free_blocks=%" PRId64 "\n", free_blocks.b);
|
|
|
|
printf(" unused_memory=%" PRId64 "\n", unused_blocks.b);
|
2008-05-22 21:28:00 +00:00
|
|
|
if (h->n_named_roots==-1) {
|
2013-04-16 23:57:18 -04:00
|
|
|
printf(" unnamed_root=%" PRId64 "\n", h->roots[0].b);
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" flags=%u\n", h->flags_array[0]);
|
2008-05-22 21:28:00 +00:00
|
|
|
} else {
|
|
|
|
printf(" n_named_roots=%d\n", h->n_named_roots);
|
|
|
|
if (h->n_named_roots>=0) {
|
|
|
|
int i;
|
|
|
|
for (i=0; i<h->n_named_roots; i++) {
|
2013-04-16 23:57:18 -04:00
|
|
|
printf(" %s -> %" PRId64 "\n", h->names[i], h->roots[i].b);
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" flags=%u\n", h->flags_array[i]);
|
2008-05-22 21:28:00 +00:00
|
|
|
}
|
2008-01-22 16:27:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*header = h;
|
2008-04-27 17:54:24 +00:00
|
|
|
printf("Fifo:\n");
|
|
|
|
printf(" fifo has %d entries\n", toku_fifo_n_entries(h->fifo));
|
2008-04-30 13:23:04 +00:00
|
|
|
if (dump_data) {
|
|
|
|
FIFO_ITERATE(h->fifo, key, keylen, data, datalen, type, xid,
|
2013-04-16 23:57:21 -04:00
|
|
|
{
|
2008-04-30 13:23:04 +00:00
|
|
|
printf(" ");
|
|
|
|
switch (type) {
|
|
|
|
case BRT_NONE: printf("NONE"); goto ok;
|
|
|
|
case BRT_INSERT: printf("INSERT"); goto ok;
|
|
|
|
case BRT_DELETE_ANY: printf("DELETE_ANY"); goto ok;
|
|
|
|
case BRT_DELETE_BOTH: printf("DELETE_BOTH"); goto ok;
|
|
|
|
case BRT_ABORT_ANY: printf("ABORT_ANY"); goto ok;
|
|
|
|
case BRT_ABORT_BOTH: printf("ABORT_BOTH"); goto ok;
|
|
|
|
case BRT_COMMIT_ANY: printf("COMMIT_ANY"); goto ok;
|
|
|
|
case BRT_COMMIT_BOTH: printf("COMMIT_BOTH"); goto ok;
|
|
|
|
}
|
|
|
|
printf("huh?");
|
|
|
|
ok:
|
|
|
|
printf(" %lld ", (long long)xid);
|
|
|
|
print_item(key, keylen);
|
|
|
|
printf(" ");
|
|
|
|
print_item(data, datalen);
|
|
|
|
printf("\n");
|
2013-04-16 23:57:21 -04:00
|
|
|
});
|
2008-04-30 13:23:04 +00:00
|
|
|
}
|
2008-01-22 19:30:02 +00:00
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static int
|
|
|
|
print_le (OMTVALUE lev, u_int32_t UU(idx), void *UU(v)) {
|
2008-07-24 21:25:31 +00:00
|
|
|
LEAFENTRY le=lev;
|
|
|
|
print_leafentry(stdout, le);
|
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static void
|
|
|
|
dump_node (int f, BLOCKNUM blocknum, struct brt_header *h) {
|
2008-01-22 16:27:54 +00:00
|
|
|
BRTNODE n;
|
2013-04-16 23:57:18 -04:00
|
|
|
int r = toku_deserialize_brtnode_from (f, blocknum, 0 /*pass zero for hash, it doesn't matter*/, &n, h);
|
2008-01-22 16:27:54 +00:00
|
|
|
assert(r==0);
|
2008-03-17 02:40:59 +00:00
|
|
|
assert(n!=0);
|
2008-01-22 19:30:02 +00:00
|
|
|
printf("brtnode\n");
|
2013-04-16 23:57:42 -04:00
|
|
|
DISKOFF disksize, diskoffset;
|
|
|
|
toku_block_get_offset_size(h->blocktable, blocknum, &diskoffset, &disksize);
|
|
|
|
printf(" diskoffset =%" PRId64 "\n", diskoffset);
|
|
|
|
printf(" disksize =%" PRId64 "\n", disksize);
|
2008-01-22 19:30:02 +00:00
|
|
|
printf(" nodesize =%u\n", n->nodesize);
|
2013-04-16 23:57:42 -04:00
|
|
|
printf(" serialize_size =%u\n", toku_serialize_brtnode_size(n));
|
2008-01-22 19:30:02 +00:00
|
|
|
printf(" flags =%u\n", n->flags);
|
2013-04-16 23:57:18 -04:00
|
|
|
printf(" thisnodename=%" PRId64 "\n", n->thisnodename.b);
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" disk_lsn =%" PRIu64 "\n", n->disk_lsn.lsn);
|
2008-01-23 18:06:23 +00:00
|
|
|
//printf(" log_lsn =%lld\n", n->log_lsn.lsn); // The log_lsn is a memory-only value.
|
2008-01-22 19:30:02 +00:00
|
|
|
printf(" height =%d\n", n->height);
|
2008-04-24 15:44:10 +00:00
|
|
|
printf(" layout_version=%d\n", n->layout_version);
|
2008-01-22 19:30:02 +00:00
|
|
|
printf(" rand4fp =%08x\n", n->rand4fingerprint);
|
|
|
|
printf(" localfp =%08x\n", n->local_fingerprint);
|
|
|
|
if (n->height>0) {
|
|
|
|
printf(" n_children=%d\n", n->u.n.n_children);
|
|
|
|
printf(" total_childkeylens=%u\n", n->u.n.totalchildkeylens);
|
|
|
|
printf(" n_bytes_in_buffers=%u\n", n->u.n.n_bytes_in_buffers);
|
|
|
|
int i;
|
|
|
|
printf(" subfingerprints={");
|
|
|
|
for (i=0; i<n->u.n.n_children; i++) {
|
|
|
|
if (i>0) printf(" ");
|
2008-01-31 22:05:43 +00:00
|
|
|
printf("%08x", BNC_SUBTREE_FINGERPRINT(n, i));
|
2008-01-22 19:30:02 +00:00
|
|
|
}
|
|
|
|
printf("}\n");
|
2008-04-30 13:23:04 +00:00
|
|
|
printf(" subleafentry_estimates={");
|
|
|
|
for (i=0; i<n->u.n.n_children; i++) {
|
|
|
|
if (i>0) printf(" ");
|
2013-04-16 23:57:20 -04:00
|
|
|
printf("%llu", (unsigned long long)(BNC_SUBTREE_LEAFENTRY_ESTIMATE(n, i)));
|
2008-04-30 13:23:04 +00:00
|
|
|
}
|
|
|
|
printf("}\n");
|
2008-01-22 19:30:02 +00:00
|
|
|
printf(" pivots:\n");
|
|
|
|
for (i=0; i<n->u.n.n_children-1; i++) {
|
|
|
|
struct kv_pair *piv = n->u.n.childkeys[i];
|
|
|
|
printf(" pivot %d:", i);
|
2013-04-16 23:57:18 -04:00
|
|
|
assert(n->flags == 0 || n->flags == TOKU_DB_DUP+TOKU_DB_DUPSORT);
|
2008-01-22 19:30:02 +00:00
|
|
|
print_item(kv_pair_key_const(piv), kv_pair_keylen(piv));
|
2013-04-16 23:57:18 -04:00
|
|
|
if (n->flags == TOKU_DB_DUP+TOKU_DB_DUPSORT)
|
|
|
|
print_item(kv_pair_val_const(piv), kv_pair_vallen(piv));
|
2008-01-22 19:30:02 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf(" children:\n");
|
|
|
|
for (i=0; i<n->u.n.n_children; i++) {
|
2013-04-16 23:57:18 -04:00
|
|
|
printf(" child %d: %" PRId64 "\n", i, BNC_BLOCKNUM(n, i).b);
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" buffer contains %u bytes (%d items)\n", BNC_NBYTESINBUF(n, i), toku_fifo_n_entries(BNC_BUFFER(n,i)));
|
2008-04-30 13:23:04 +00:00
|
|
|
if (dump_data) {
|
|
|
|
FIFO_ITERATE(BNC_BUFFER(n,i), key, keylen, data, datalen, typ, xid,
|
2013-04-16 23:57:21 -04:00
|
|
|
{
|
2008-04-30 13:23:04 +00:00
|
|
|
printf(" TYPE=");
|
|
|
|
switch ((enum brt_cmd_type)typ) {
|
|
|
|
case BRT_NONE: printf("NONE"); goto ok;
|
|
|
|
case BRT_INSERT: printf("INSERT"); goto ok;
|
|
|
|
case BRT_DELETE_ANY: printf("DELETE_ANY"); goto ok;
|
|
|
|
case BRT_DELETE_BOTH: printf("DELETE_BOTH"); goto ok;
|
|
|
|
case BRT_ABORT_ANY: printf("ABORT_ANY"); goto ok;
|
|
|
|
case BRT_ABORT_BOTH: printf("ABORT_BOTH"); goto ok;
|
|
|
|
case BRT_COMMIT_ANY: printf("COMMIT_ANY"); goto ok;
|
|
|
|
case BRT_COMMIT_BOTH: printf("COMMIT_BOTH"); goto ok;
|
|
|
|
}
|
|
|
|
printf("HUH?");
|
|
|
|
ok:
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" xid=%"PRIu64" ", xid);
|
2008-04-30 13:23:04 +00:00
|
|
|
print_item(key, keylen);
|
|
|
|
if (datalen>0) {
|
|
|
|
printf(" ");
|
|
|
|
print_item(data, datalen);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2013-04-16 23:57:21 -04:00
|
|
|
}
|
2008-04-30 13:23:04 +00:00
|
|
|
);
|
|
|
|
}
|
2008-01-22 19:30:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-04-16 23:57:20 -04:00
|
|
|
printf(" n_bytes_in_buffer=%u\n", n->u.l.n_bytes_in_buffer);
|
|
|
|
printf(" items_in_buffer =%u\n", toku_omt_size(n->u.l.buffer));
|
2008-04-30 13:23:04 +00:00
|
|
|
if (dump_data) toku_omt_iterate(n->u.l.buffer, print_le, 0);
|
2013-04-16 23:57:25 -04:00
|
|
|
} toku_brtnode_free(&n);
|
2008-01-18 16:01:25 +00:00
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static void
|
|
|
|
dump_block_translation(struct brt_header *h, u_int64_t offset) {
|
2013-04-16 23:57:41 -04:00
|
|
|
toku_block_dump_translation(h->blocktable, offset);
|
2013-04-16 23:57:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bxpcmp(const void *a, const void *b) {
|
|
|
|
const struct block_translation_pair *bxpa = a;
|
|
|
|
const struct block_translation_pair *bxpb = b;
|
|
|
|
if (bxpa->diskoff < bxpb->diskoff) return -1;
|
|
|
|
if (bxpa->diskoff > bxpb->diskoff) return +1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-16 23:57:21 -04:00
|
|
|
dump_fragmentation(int f, struct brt_header *h) {
|
|
|
|
u_int64_t blocksizes = 0;
|
|
|
|
u_int64_t leafsizes = 0;
|
|
|
|
u_int64_t leafblocks = 0;
|
|
|
|
u_int64_t fragsizes = 0;
|
2013-04-16 23:57:20 -04:00
|
|
|
u_int64_t i;
|
2013-04-16 23:57:41 -04:00
|
|
|
u_int64_t limit = toku_block_get_translated_blocknum_limit(h->blocktable);
|
|
|
|
for (i = 0; i < limit; i++) {
|
2013-04-16 23:57:21 -04:00
|
|
|
BRTNODE n;
|
|
|
|
BLOCKNUM blocknum = make_blocknum(i);
|
|
|
|
int r = toku_deserialize_brtnode_from (f, blocknum, 0 /*pass zero for hash, it doesn't matter*/, &n, h);
|
|
|
|
if (r != 0) continue;
|
2013-04-16 23:57:41 -04:00
|
|
|
|
|
|
|
DISKOFF size = toku_block_get_size(h->blocktable, blocknum);
|
|
|
|
blocksizes += size;
|
2013-04-16 23:57:21 -04:00
|
|
|
if (n->height == 0) {
|
2013-04-16 23:57:41 -04:00
|
|
|
leafsizes += size;
|
2013-04-16 23:57:21 -04:00
|
|
|
leafblocks += 1;
|
|
|
|
}
|
|
|
|
toku_brtnode_free(&n);
|
2013-04-16 23:57:20 -04:00
|
|
|
}
|
2013-04-16 23:57:41 -04:00
|
|
|
size_t n = limit * sizeof (struct block_translation_pair);
|
2013-04-16 23:57:33 -04:00
|
|
|
struct block_translation_pair *bx = toku_malloc(n);
|
2013-04-16 23:57:41 -04:00
|
|
|
toku_block_memcpy_translation_table(h->blocktable, n, bx);
|
|
|
|
qsort(bx, limit, sizeof (struct block_translation_pair), bxpcmp);
|
|
|
|
for (i = 0; i < limit - 1; i++) {
|
2013-04-16 23:57:21 -04:00
|
|
|
// printf("%lu %lu %lu\n", i, bx[i].diskoff, bx[i].size);
|
|
|
|
fragsizes += bx[i+1].diskoff - (bx[i].diskoff + bx[i].size);
|
2013-04-16 23:57:20 -04:00
|
|
|
}
|
2013-04-16 23:57:33 -04:00
|
|
|
toku_free(bx);
|
2013-04-16 23:57:41 -04:00
|
|
|
printf("translated_blocknum_limit: %" PRIu64 "\n", limit);
|
2013-04-16 23:57:26 -04:00
|
|
|
printf("leafblocks: %" PRIu64 "\n", leafblocks);
|
|
|
|
printf("blocksizes: %" PRIu64 "\n", blocksizes);
|
|
|
|
printf("leafsizes: %" PRIu64 "\n", leafsizes);
|
|
|
|
printf("fragsizes: %" PRIu64 "\n", fragsizes);
|
2013-04-16 23:57:21 -04:00
|
|
|
printf("fragmentation: %.1f%%\n", 100. * ((double)fragsizes / (double)(fragsizes + blocksizes)));
|
2013-04-16 23:57:20 -04:00
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:46 -04:00
|
|
|
static void
|
|
|
|
hex_dump(unsigned char *vp, u_int64_t offset, u_int64_t size) {
|
|
|
|
u_int64_t i;
|
|
|
|
for (i=0; i<size; i++) {
|
|
|
|
if ((i % 32) == 0)
|
|
|
|
printf("%"PRIu64": ", offset+i);
|
|
|
|
printf("%2.2X", vp[i]);
|
|
|
|
if (((i+1) % 4) == 0)
|
|
|
|
printf(" ");
|
|
|
|
if (((i+1) % 32) == 0)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dump_file(int f, u_int64_t offset, u_int64_t size) {
|
|
|
|
unsigned char *vp = toku_malloc(size);
|
|
|
|
u_int64_t r = pread(f, vp, size, offset);
|
|
|
|
if (r == size)
|
|
|
|
hex_dump(vp, offset, size);
|
|
|
|
toku_free(vp);
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static void
|
|
|
|
readline (char *line, int maxline) {
|
2013-04-16 23:57:18 -04:00
|
|
|
int i = 0;
|
|
|
|
int c;
|
|
|
|
while ((c = getchar()) != EOF && c != '\n' && i < maxline) {
|
2013-04-16 23:57:20 -04:00
|
|
|
line[i++] = (char)c;
|
2013-04-16 23:57:18 -04:00
|
|
|
}
|
|
|
|
line[i++] = 0;
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
static int
|
|
|
|
split_fields (char *line, char *fields[], int maxfields) {
|
2013-04-16 23:57:18 -04:00
|
|
|
int i;
|
|
|
|
for (i=0; i<maxfields; i++, line=NULL) {
|
|
|
|
fields[i] = strtok(line, " ");
|
|
|
|
if (fields[i] == NULL) break;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:39 -04:00
|
|
|
static int
|
|
|
|
usage(const char *arg0) {
|
|
|
|
printf("Usage: %s [--nodata] [--interactive] brtfilename\n", arg0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:22 -04:00
|
|
|
int
|
|
|
|
main (int argc, const char *argv[]) {
|
2008-04-30 13:23:04 +00:00
|
|
|
const char *arg0 = argv[0];
|
2013-04-16 23:57:39 -04:00
|
|
|
int interactive = 0;
|
2008-04-30 13:23:04 +00:00
|
|
|
argc--; argv++;
|
2013-04-16 23:57:39 -04:00
|
|
|
while (argc>0) {
|
|
|
|
if (strcmp(argv[0], "--nodata") == 0) {
|
2008-04-30 13:23:04 +00:00
|
|
|
dump_data = 0;
|
2013-04-16 23:57:44 -04:00
|
|
|
} else if (strcmp(argv[0], "--interactive") == 0 || strcmp(argv[0], "--i") == 0) {
|
2013-04-16 23:57:18 -04:00
|
|
|
interactive = 1;
|
2013-04-16 23:57:39 -04:00
|
|
|
} else if (strcmp(argv[0], "--help") == 0) {
|
|
|
|
return usage(arg0);
|
|
|
|
} else
|
|
|
|
break;
|
2008-04-30 13:23:04 +00:00
|
|
|
argc--; argv++;
|
|
|
|
}
|
2013-04-16 23:57:39 -04:00
|
|
|
if (argc != 1) return usage(arg0);
|
|
|
|
|
2008-04-30 13:23:04 +00:00
|
|
|
const char *n = argv[0];
|
2013-04-16 23:57:27 -04:00
|
|
|
int f = open(n, O_RDONLY + O_BINARY); assert(f>=0);
|
2008-01-22 16:27:54 +00:00
|
|
|
struct brt_header *h;
|
|
|
|
dump_header(f, &h);
|
2013-04-16 23:57:18 -04:00
|
|
|
if (interactive) {
|
|
|
|
while (1) {
|
|
|
|
printf("brtdump>"); fflush(stdout);
|
2013-04-16 23:57:20 -04:00
|
|
|
enum { maxline = 64};
|
2013-04-16 23:57:18 -04:00
|
|
|
char line[maxline+1];
|
|
|
|
readline(line, maxline);
|
|
|
|
if (strcmp(line, "") == 0)
|
|
|
|
break;
|
2013-04-16 23:57:46 -04:00
|
|
|
const int maxfields = 4;
|
2013-04-16 23:57:18 -04:00
|
|
|
char *fields[maxfields];
|
|
|
|
int nfields = split_fields(line, fields, maxfields);
|
|
|
|
if (nfields == 0)
|
|
|
|
continue;
|
|
|
|
if (strcmp(fields[0], "header") == 0) {
|
|
|
|
toku_brtheader_free(h);
|
|
|
|
dump_header(f, &h);
|
|
|
|
} else if (strcmp(fields[0], "node") == 0 && nfields == 2) {
|
|
|
|
BLOCKNUM off = make_blocknum(strtoll(fields[1], NULL, 10));
|
|
|
|
dump_node(f, off, h);
|
2013-04-16 23:57:18 -04:00
|
|
|
} else if (strcmp(fields[0], "dumpdata") == 0 && nfields == 2) {
|
|
|
|
dump_data = strtol(fields[1], NULL, 10);
|
2013-04-16 23:57:20 -04:00
|
|
|
} else if (strcmp(fields[0], "block_translation") == 0 || strcmp(fields[0], "bx") == 0) {
|
|
|
|
u_int64_t offset = 0;
|
|
|
|
if (nfields == 2)
|
|
|
|
offset = strtoll(fields[1], NULL, 10);
|
|
|
|
dump_block_translation(h, offset);
|
|
|
|
} else if (strcmp(fields[0], "fragmentation") == 0) {
|
2013-04-16 23:57:21 -04:00
|
|
|
dump_fragmentation(f, h);
|
2013-04-16 23:57:46 -04:00
|
|
|
} else if (strcmp(fields[0], "file") == 0 && nfields == 3) {
|
|
|
|
u_int64_t offset, size;
|
|
|
|
if (strncmp(fields[1], "0x", 2) == 0)
|
|
|
|
offset = strtoll(fields[1], NULL, 16);
|
|
|
|
else
|
|
|
|
offset = strtoll(fields[1], NULL, 10);
|
|
|
|
if (strncmp(fields[2], "0x", 2) == 0)
|
|
|
|
size = strtoll(fields[2], NULL, 16);
|
|
|
|
else
|
|
|
|
size = strtoll(fields[2], NULL, 10);
|
|
|
|
dump_file(f, offset, size);
|
2013-04-16 23:57:18 -04:00
|
|
|
} else if (strcmp(fields[0], "quit") == 0 || strcmp(fields[0], "q") == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
BLOCKNUM blocknum;
|
2013-04-16 23:57:25 -04:00
|
|
|
printf("Block translation:");
|
2013-04-16 23:57:41 -04:00
|
|
|
|
|
|
|
u_int64_t limit = toku_block_get_translated_blocknum_limit(h->blocktable);
|
|
|
|
BLOCKNUM unused_blocks = toku_block_get_unused_blocks(h->blocktable);
|
|
|
|
size_t bx_size = limit * sizeof (struct block_translation_pair);
|
|
|
|
struct block_translation_pair *bx = toku_malloc(bx_size);
|
|
|
|
toku_block_memcpy_translation_table(h->blocktable, bx_size, bx);
|
|
|
|
|
|
|
|
|
|
|
|
for (blocknum.b=0; blocknum.b< unused_blocks.b; blocknum.b++) {
|
2013-04-16 23:57:25 -04:00
|
|
|
printf(" %" PRId64 ":", blocknum.b);
|
2013-04-16 23:57:41 -04:00
|
|
|
if (bx[blocknum.b].size == -1) printf("free");
|
|
|
|
else printf("%" PRId64 ":%" PRId64, bx[blocknum.b].diskoff, bx[blocknum.b].size);
|
2013-04-16 23:57:25 -04:00
|
|
|
}
|
2013-04-16 23:57:41 -04:00
|
|
|
for (blocknum.b=1; blocknum.b<unused_blocks.b; blocknum.b++) {
|
|
|
|
if (bx[blocknum.b].size != -1)
|
2013-04-16 23:57:25 -04:00
|
|
|
dump_node(f, blocknum, h);
|
2013-04-16 23:57:18 -04:00
|
|
|
}
|
2013-04-16 23:57:41 -04:00
|
|
|
toku_free(bx);
|
2008-01-22 19:30:02 +00:00
|
|
|
}
|
2008-05-22 21:28:00 +00:00
|
|
|
toku_brtheader_free(h);
|
|
|
|
toku_malloc_cleanup();
|
2008-01-18 16:01:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|