Skip to content

Commit

Permalink
(#533) Add print fn to print branch BTrees under trunk node.
Browse files Browse the repository at this point in the history
- Introduce trunk_print_branch_btrees() to walk the root-addresses
  of branch BTree nodes for a given trunk node, and to invoke the
  BTree print methods on each such branch. The top-level BTree
  root node is being printed right, but upon recursing down, we
  are running into an unallocated page error.
  allocator_page_valid() is consistently failing for all sub-trees
  under root branch BTree.
  • Loading branch information
gapisback committed Feb 3, 2023
1 parent 23c0164 commit e626968
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/trunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,10 @@ trunk_get_memtable(trunk_handle *spl, uint64 generation)
{
uint64 memtable_idx = generation % TRUNK_NUM_MEMTABLES;
memtable *mt = &spl->mt_ctxt->mt[memtable_idx];
platform_assert(mt->generation == generation);
platform_assert((mt->generation == generation),
"mt->generation=%lu, generation=%lu\n",
mt->generation,
generation);
return mt;
}

Expand Down Expand Up @@ -9007,6 +9010,41 @@ trunk_print_branches(platform_log_handle *log_handle, trunk_handle *spl)
trunk_for_each_node(spl, trunk_node_print_branches, log_handle);
}

/*
* Print all the branch BTrees hanging off of input trunk node 'addr'.
*/
void
trunk_print_branch_btrees(trunk_handle *spl, uint64 addr, void *arg)
{
platform_log_handle *log_handle = (platform_log_handle *)arg;
trunk_node node;
trunk_node_get(spl->cc, addr, &node);

uint16 start_branch = trunk_start_branch(spl, &node);
uint16 end_branch = trunk_end_branch(spl, &node);

platform_log(log_handle,
"\n**** Print all BTree branches under "
"Trunk node addr=%lu ****\n{\n\n",
addr);
for (uint16 branch_no = start_branch; branch_no != end_branch;
branch_no = trunk_add_branch_number(spl, branch_no, 1))
{
uint64 bt_addr = trunk_get_branch(spl, &node, branch_no)->root_addr;
platform_log(log_handle,
"Trunk node addr=%lu, Branch number %u"
", BTree root addr=%lu\n{\n",
addr,
branch_no,
bt_addr);
btree_print_tree(log_handle, spl->cc, trunk_btree_config(spl), bt_addr);
platform_log(log_handle, "\n}\n");
}

trunk_node_unget(spl->cc, &node);
platform_log(log_handle, "\n}\n");
}

// bool
// trunk_node_print_extent_count(trunk_handle *spl,
// uint64 addr,
Expand Down
6 changes: 6 additions & 0 deletions src/trunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,16 @@ trunk_print_lookup(trunk_handle *spl,
platform_log_handle *log_handle);
void
trunk_print_branches(platform_log_handle *log_handle, trunk_handle *spl);

void
trunk_print_extent_counts(platform_log_handle *log_handle, trunk_handle *spl);

void
trunk_print_branch_btrees(trunk_handle *spl, uint64 addr, void *arg);

void
trunk_print_space_use(platform_log_handle *log_handle, trunk_handle *spl);

bool
trunk_verify_tree(trunk_handle *spl);

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/splinter_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ CTEST2(splinter, test_splinter_print_diags)
CTEST_LOG_INFO("\n** trunk_print() **\n");
trunk_print(Platform_default_log_handle, spl);

CTEST_LOG_INFO("\n** trunk_print_branch_btrees() on Trunk root node **\n");
trunk_print_branch_btrees(spl, spl->root_addr, Platform_default_log_handle);

CTEST_LOG_INFO("\n** Allocator stats **\n");
allocator_print_stats(alp);
allocator_print_allocated(alp);
Expand Down

0 comments on commit e626968

Please sign in to comment.