[Tux3] dleaf ordered check

Daniel Phillips phillips at phunq.net
Wed Sep 3 03:20:08 PDT 2008


For what it is worth, here is quite a different formulation of a dleaf
walker, which is close to what I need for truncate.  With this style
it is easy to jump into the process exactly where necessary, which
would be messier with the nested loop form.

void entry_dump(struct dleaf *leaf, tuxkey_t key, unsigned off, unsigned num)
{
	printf(" %Lx ->", (L)key);
	for (int i = 0; i < num; i++)
		printf(" %Lx", (L)leaf->table[off + i].block);
	printf(";");
}

void dleaf_walk(BTREE, struct dleaf *leaf)
{
	dleaf_dump(btree, leaf);
	struct group *group = (void *)leaf + btree->sb->blocksize;
	struct entry *entry = (void *)(--group - leaf->groups);
	struct group *gstop = group - leaf->groups;
	struct entry *estop = entry - group->count;
	unsigned extents = 0, start = 0;
	while (1) {
		unsigned count = entry->limit - start;
		tuxkey_t key = ((tuxkey_t)group->loghi << 24) | entry->loglo;
		entry_dump(leaf, key, extents, count);
		start = entry->limit;
		extents += count;
		if (--entry != estop)
			continue;
		printf("\n");
		if (--group == gstop)
			return;
		estop = entry - group->count;
		start = 0;
	}
}

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list