[Tux3] current my atomic-commit prototype (v2)

OGAWA Hirofumi hirofumi at mail.parknet.co.jp
Fri May 15 09:29:59 PDT 2009


OGAWA Hirofumi <hirofumi at mail.parknet.co.jp> writes:

> BTW, maybe, I found the bug of insert_leaf(). The cursor should have the
> corrent path to leaf, however, after insert_leaf(), it may not have the
> corrent path. Because, it sets the bnode of splited to cursor, but the
> splited bnode may not be the path to leaf.

OK, I think I've found the bug of insert_leaf(). Current code updates
the childblock/childkey to the splited new block blindly. It means this
is assuming the splited new block has inserting leaf.

But, it is not true. So, this patch fixes the cursor position only if
splited new block has target child.

Maybe, I'll make the bug-fix patchset like this, and post.

Thanks.

diff -puN user/kernel/btree.c~insert_leaf-cursor-path-fix user/kernel/btree.c
--- tux3/user/kernel/btree.c~insert_leaf-cursor-path-fix	2009-05-16 00:30:58.000000000 +0900
+++ tux3-hirofumi/user/kernel/btree.c	2009-05-16 01:19:06.000000000 +0900
@@ -649,7 +649,8 @@ static int insert_leaf(struct cursor *cu
 		parent->count = to_be_u32(half);
 
 		/* if the cursor is in the new node, use that as the parent */
-		if (at->next > parent->entries + half) {
+		int child_is_left = at->next <= parent->entries + half;
+		if (!child_is_left) {
 			struct index_entry *newnext;
 			mark_buffer_dirty(parentbuf);
 			newnext = newnode->entries + (at->next - &parent->entries[half]);
@@ -663,9 +664,17 @@ static int insert_leaf(struct cursor *cu
 		if (!keep)
 			at->next++;
 		mark_buffer_dirty(parentbuf);
+
 		childkey = newkey;
 		childblock = bufindex(newbuf);
 		blockput(newbuf);
+
+		/*
+		 * if child is in left bnode, we should keep the
+		 * cursor position to child, not splited new bnode.
+		 */
+		if (child_is_left)
+			keep = 1;
 	}
 	trace("add tree level");
 	struct buffer_head *newbuf = new_node(btree);
_

-- 
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>

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



More information about the Tux3 mailing list