Пример #1
0
void bt_dump_node (char *label, BtNode_s *node)
{
	printf("%s %p:::%s %d:::\n",
		label, node, pr_is_leaf(node), node->num);
	if (node->is_leaf) {
		dump_leaf(node);
	} else {
		dump_branch(node);
	}
}
Пример #2
0
Файл: btree.c Проект: taysom/tau
void verify_leaf (tree_s *tree, leaf_s *leaf, char *where)
{
	int	sum;
	int	i;

	if (leaf->l_type != LEAF) {
		printf("ERROR:%s leaf=%p type=%d\n",
			where, leaf, leaf->l_type);
		exit(3);
	}
	if (leaf->l_total < free_space(leaf)) {
		printf("ERROR:%s allocation space bigger than total\n",
			where);
		dump_leaf(tree, leaf, 0);
		exit(3);
	}
	if (free_space(leaf) < 0) {
		printf("ERROR:%s leaf overflow\n", where);
		dump_leaf(tree, leaf, 0);
		exit(3);
	}
	sum = sizeof(leaf_s) + (leaf->l_num * sizeof(rec_s));
	for (i = 0; i < leaf->l_num; i++) {
		sum += leaf->l_rec[i].r_len;
	}
	if (BLK_SIZE - sum != leaf->l_total) {
		printf("ERROR:%s totals %d != %d\n", where,
			BLK_SIZE - sum, leaf->l_total);
		dump_leaf(tree, leaf, 0);
		exit(3);
	}
	for (i = 1; i < leaf->l_num; i++) {
		if (leaf->l_rec[i-1].r_key >= leaf->l_rec[i].r_key) {
			printf("ERROR:%s keys out of order %llu >= %llu\n",
				where,
				leaf->l_rec[i-1].r_key, leaf->l_rec[i].r_key);
			dump_leaf(tree, leaf, 0);
			exit(3);
		}
	}

}
Пример #3
0
static void verify_leaf (tree_s *tree, leaf_s *leaf, char *where)
{
	snint	sum;
	unint	i;

	if (leaf->h_magic != LEAF) {
		eprintk("ERROR:%s leaf=%p magic=%x\n",
			where, leaf, leaf->h_magic);
		BUG();
	}
	if (leaf->l_total < free_space(leaf)) {
		eprintk("ERROR:%s allocation space bigger than total\n",
			where);
		dump_leaf(tree, leaf, 0);
		BUG();
	}
	if (free_space(leaf) < 0) {
		eprintk("ERROR:%s leaf overflow\n", where);
		dump_leaf(tree, leaf, 0);
		BUG();
	}
	sum = sizeof(leaf_s) + (leaf->l_num * sizeof(rec_s));
	for (i = 0; i < leaf->l_num; i++) {
		sum += leaf->l_rec[i].r_size;
	}
	if (BLK_SIZE - sum != leaf->l_total) {
		eprintk("ERROR:%s totals %ld != %d\n", where,
			BLK_SIZE - sum, leaf->l_total);
		dump_leaf(tree, leaf, 0);
		BUG();
	}
	for (i = 1; i < leaf->l_num; i++) {
		if (leaf->l_rec[i-1].r_key >= leaf->l_rec[i].r_key) {
			eprintk("ERROR:%s keys out of order %llx >= %llx\n",
				where,
				leaf->l_rec[i-1].r_key, leaf->l_rec[i].r_key);
			dump_leaf(tree, leaf, 0);
			BUG();
		}
	}

}
Пример #4
0
void dump_node (
	tree_s	*tree,
	void	*node,
	unint	depth)
{
	head_s	*h = node;

	printf("node=%p\n", node);
	switch (h->h_magic) {
	case LEAF:	dump_leaf(tree, (leaf_s *)h, depth);
			break;
	case BRANCH:	dump_branch(tree, (branch_s *)h, depth);
			break;
	default:	prmem("Unknown block magic", h, PAGE_SIZE);
			break;
	}
}
Пример #5
0
Файл: btree.c Проект: taysom/tau
void dump_block (
	tree_s	*tree,
	u64	blkno,
	unint	indent)
{
	void	*data;

//FN;
	data = bget(tree->t_dev, blkno);
	if (!data) return;

	switch (type(data)) {
	case LEAF:	dump_leaf(tree, data, indent);
			break;
	case BRANCH:	dump_branch(tree, data, indent);
			break;
	default:	prmem("Unknown block type", data, BLK_SIZE);
			break;
	}
	bput(data);
}
Пример #6
0
static void dump_node (
	tree_s	*tree,
	u64	blknum,
	unint	depth)
{
	head_s	*h;

	h = tau_bget(tree_inode(tree), blknum);
	if (!h) return;

	dprintk("blknum=%llx\n", tau_bnum(h));
	switch (h->h_magic) {
	case LEAF:	dump_leaf(tree, (leaf_s *)h, depth);
			break;
	case BRANCH:	dump_branch(tree, (branch_s *)h, depth);
			break;
	default:	tau_prmem("Unknown block magic", h, BLK_SIZE);
			break;
	}
	tau_bput(h);
}